Welcome to the Treehouse Community
Looking to learn something new?
I have two silly questions: 1) what does +1 or ++ do exactly 2)why does var = correctAnswers equal zero?
Steven Parker216,012 Points
+1" is just "and one more", but I'm thinking you might have meant "
+= 1" using the addition assignment operator which means "increment by one". Now "
++" is the increment operator, which will also increment something by one, but it comes in two "flavors" depending on which side of the operand you put it. If you're using these as complete staements, all 3 do the same thing. But in expressions, the post-increment operator (when you put "
++" after the operand) has the value of the operand before it is incremented. You probably won't use that in any beginner exercises.
I'm not sure I understand question 2. I would expect "
var = correctAnswers" to be a syntax error, since "var" is a keyword used to create variables and there's no variable name between it and the equal sign. Even if that's not what you meant to write, I'd probably need to see a lot more of the code to determine why something was getting a value of zero.
For future questions, remember to use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. Or watch this video on code formatting.