Can someone please help me understand why the following array length increments without having a counter.
var inputName = "";
var namesArray = new Array();
while ( (inputName = prompt("Enter a name", "")) != "") {
namesArray[namesArray.length] = inputName;
}
namesArray.sort();
var namesList = namesArray.join("\n");
console.log(namesList);
So from this I am assuming, a while loop increments any value you include inside the while loop. I had a look at MDN While Loop and I can see that both the x in this example is also incrementing.
I just want to be sure that I got this correct but mainly understand why it does this.
Thanks