# Difference between count++ and count+1?

#1

Ok so I got this exercise to work but I have a question I can't wrap my head around. This while function works when I use count++ (on line 6) which to my understanding is saying add 1 to the count variable at the start of each loop. However when I use count+1 instead of count++, which to my understanding is the same thing? I create an infinite loop? I'm clearly missing something but I'm not sure what? Can anyone explain?

``````var count = 1

var soloLoop = function(count){
while (count < 2){
console.log ("Looped once!")
count++
}

};

soloLoop(count);

Replace this line with your code.``````

#2

javascript reads: count+1 it's not assigning a new value to count because of incorrect syntax.
Try using count+=1 which now reads as count = count + 1

#3

Thanks so much! This was driving me mad!

#4

``count++``

is the same thing as

``count = count + 1``

It means the exact same thing, but the first one uses less code. It is more clear to read, especially the further one is in this and other languages. It's kinda the same thing as the expression "4 * 6" and someone wrote this as "4 + 4 + 4 + 4 + 4 + 4." One is very clear and the other (the latter) is not and could be confusing or miscounted easily.

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.