Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
I have two silly questions: 1) what does +1 or ++ do exactly 2)why does var = correctAnswers equal zero?
Steven Parker227,114 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.