I was wondering what exactly my code is missing or why it wont work
<script>
var index = 0;
var name = [];
while (true)
{
var add = window.confirm("Would you like to enter an employee");
if (add === true)
{
name[index] = prompt("Please enter and employee name");
++index;
}
else
break;
}
window.alert(name[0]);
</script>
The window.alert is just to see if it gets saved, Im trying to use c++ style in JS, I know I maybe should be doing the push method? But Im not really sure, all it says in the alert box is undefined, and Im not really sure why, any help would be greatly appreciated, thank you. And Im not really sure what is, and what isnt allowed in javascript, I assumed things like incrementing are the same in bot JS and C++.