Елена Ом Елена Ом - 10 months ago 56
Javascript Question

How to fill empty array with "for loop" and "prompt(' ')" in javascript

I have written:

var arr = [];
for (i = 0; i < 5; i++) {
var name = prompt('please, enter your name');


But it is does not work. It asks me only once, but I need to make arrey with five names. Please help me to find my mistake.

Answer Source

It worked for me. Are you using Google Chrome to test. Maybe something for above it is interrupting. Try it on a new Javascript File. If you're using Chrome to test what is the log saying Ctrl + Shift + J let me know.

Thanks :)