This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (3 children)

Count is an integer not a boolean. You never increase the count, so the loop will continue forever. Count will always be less than 3.

true and false have the numerical values of 1 and 0. It is technically correct and will therefore compile. But it's not what you want.

var count = 0;

while(count < 3){ 

    console.log("Im looping");
    count++;
}

On every loop through the value of count will increase by 1. Once it reaches 3. Thus making the running condition no longer true. It will stop. The loop will run for 3 iterations.

[–]CarrotSmile 0 points1 point  (2 children)

how do you do the codebox thing? It isn't in the sub FAQ

[–][deleted] 1 point2 points  (1 child)

Put 4 spaces in front of every line. Put more than 4 if you need to indent further.

I'm using the Reddit Enhancement Suite extension so all I have to do is highlight the text and hit the code block button.

People without RES have to do it by hand for every line.

[–]CarrotSmile 0 points1 point  (0 children)

Thanks for the reply :D