Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

John Moron
1,658 PointsWhat is the value of totalScore? var totalScore = 10 - 20 ++totalScore
I don't understand this question.
3 Answers

Logan R
22,989 PointsWhat is the value of totalScore?
var totalScore = 10 - 20
++totalScore
So what is happening is it is declaring a variable called totalScore. Total score is initialized with (10 - 20), so the initial value of totalScore is equal to -10.
With the ++ and -- operator, it is the same as saying:
totalScore = totalScore + 1
It is just a really shortened way of saying it.
The answer to the question is -9.
var totalScore = 10 - 20 // This equals -10
++totalScore // This takes -10 and adds one to make -9

agreatdaytocode
24,757 PointsHi John
If you put this into a playground file you will get the answer
var totalScore = 10 - 20 \\ - 10
++totalScore \\ -9

John Moron
1,658 Pointsohh I got it now thanks.

Logan R
22,989 PointsNo problem! If you need any further clarification, just simply ask :)

John Moron
1,658 PointsI will do that :)