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

JavaScript

Having trouble adjusting the game score once the player collects the poison or star.

Nothing is happening when using this below.

// when the player collects an item on the screen function itemHandler(player, item) { item.kill(); if (item.key === 'coin') { currentScore = currentScore + 10; } else if (item.key === 'poison') { currentScore === currentScore - 25; } else if (item.key === 'star') { currentScore === currentScore + 25;

} if (currentScore === winningScore) { createBadge(); } }

2 Answers

Steven Parker
Steven Parker
243,160 Points

Remember that two or three equal signs are comparison operators. They evaluate things but make no changes.

To change a value, you would use the assignment operator, which is just one equal sign. Look at the code that adds 10 points for a coin as an example.

That did it!