Forum Discussion

VirginiaSus3's avatar
Occasional Contributor
2 years ago

Can you increment results within a for loop?

Is there a way to add results in a for loop, while retaining the previous result so I can verify the entire list as items are added? Macys My Insite

var listArray = new Array();
listArray[0] = item1 = "100??";
listArray[1] = item2 = "20*0*";
listArray[2] = item3 = "x26*s";

for(i = 0; i < listArray.length; i++)
    _M.Btn(_filter, "Add").ClickButton();


As the loop continues, I want the Log.Message to add each array item, while retaining the previous array item:

Log.Message(item[i] + "," + item[i] + "," + item[i]);

2 Replies

  • rraghvani's avatar
    Champion Level 3

    Are you able to provide what the expected output is supposed to look like please?

  • Marsha_R's avatar
    Champion Level 3

    Add each item to the end of a variable as you go and then put the variable out in the log message. 


    var myitems


    /* inside the for loop


    myitems = myitems + "," + Item[i]