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 trialTim Wiklund
746 PointsChallenge Task 1 of 2 I need help with this code
var initialScore = 8
initialScore = ++initialScore
var totalScore = initialScore totalScore = initialScore -1
// Enter your code below
var initialScore = 8
initialScore = ++initialScore
var totalScore = initialScore
totalScore = initialScore -1
2 Answers
Lindsay Sauer
12,029 PointsThe challenge asks for totalScore to be a constant, which needs to be declared with let instead of var.
You can also minimize the code by directly assigning the incremented value of initialScore to totalScore:
var initialScore = 8;
let totalScore = ++initialScore;
Tim Wiklund
746 PointsThanks for the quick replay :O)