Help! JavaScript Looping through Numbers
Go to solution
Solved by Mr_KoKa,
for(i=0; i<num; i++) { number[i] = num; //Think about this line }
You prompt user for input once, you set num variable once, so when you iterate from 0 to num - 1 and set every index of number array to num there is no surprise that all indexes are equal to num. It is i variable what changes trough iterations, it goes from 0 to num - 1 so to set it form 1 to num you would need to add 1.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now