increment in for loop javascript -


i don't know why can't increment value in loop normally.

for (var = 0; < 5; i++) { var number= 0 number++ console.log(number); } 

that's simple example,and 5 times number 1 in console,insted of 0,1,2,3,4. how can make work?

you're declaring variable inside loop, happens every time loop runs. move declaration outside...

var number = 0;  (var = 0; < 5; i++) {     number++;     console.log(number); } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -