Welcome to the Treehouse Community
Looking to learn something new?
I do not get the postfix ++ unary operator
Why does this give me 0 in the result pane, but when I type it again, it gives me 1. Take a look!
var scoreExample = 0 scoreExample++ scoreExample //when I type it again, it is 1... why?
The operator ++ increments values one by one. Here is an example
var someScore = 0 // someScore is now 0 // if I want to increment “someScore” by ONE, I can do it like this someScore++ // this will equal now to 1 // if I do it again someScore++ // this will equal 2 now. // Say that I now want to bring the “someScore” back to 0 someScore = 0 // this will RESET the someScore back to 0
The ++ operator increments a value by one, the -- operator decrements a value by one.
Hope that clears it
Caleb KleveterTreehouse Moderator 37,862 Points
Is that all your code? Is there a printf statement?