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! While you're at it, check out some resources Treehouse students have shared here.

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

iOS

Unary Operators

Hi! I have some issues when it comes to unary operators... I just happen to not understand them, especially this question that came up on the quiz : var totalScore = 10 - 20 ++totalScore

why is the answer equal to -9???

1 Answer

Hello Egor:

There is nothing wrong with your code, but you are subtracting 10 - 20 which will give you a negative number -10. What you have to do is change it to subtract 20 - 10, and this will give you 10, then if you want to increment, then you use the ++ operator.

var totalScore = 20 - 10 // This will be equal to 10

totalScore++ // will equal to 11 

Keep going :) it will get better