var arr[2];
for(i=0; i<arr.length; i++) {
arr[i] = prompt() * 1;
}
But i was wondering you can do like var arr = [x,y,z] = [1,2,3]; can you do a loop for "x, y, z" with a prompt?
You could also do this by using the Array() constructor and Array#map(). The Array#fill() is necessary in order to let map iterate through the whole array:
var [x, y, z] = Array(3).fill().map(prompt).map(Number)
console.log(x, y, z)
This approach uses the destructuring assignment syntax.
Just create an array with prompts and assign it to variables:
var prompts = [
prompt('0', '0'),
prompt('1', '1'),
prompt('2', '2'),
];
var [x, y, z] = prompts;
console.log(x, y, z);
prompt()... FYI, I'm not the one that downvoted, I'm just making an observation.prompt()?