Forum Discussion

KellyWiegand's avatar
KellyWiegand
Occasional Contributor
2 years ago

How to add a half-Auto-Increment variable?

Hi, I want to add a variable which is like 'test10','test11','test12','test13'......it had a string part, and the number part can auto-increase. It's better if it can be a random number. I know it ...
  • rraghvani's avatar
    2 years ago

    For example,

    function main()
    {
        var name = "Test";
        var number = 0;
        
        for (var i = 0; i < 10; i++) {
            number = i; // increment
            Log.Message(name + number.toString());
        }
        
        Log.Message(Math.floor(Math.random() * 10)); // Returns a random integer from 0 to 9
    }