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'm stuck. What am I missing here? I think I need to add in "let isWinner != totalscore = 10"
Not sure how to properly write this
// Enter your code below var initialScore = 8 var totalScore = initialScore totalScore = ++initialScore let isWinner != 10
Michael Reining10,101 Points
You are close. However, there are a few things wrong.
As always, I recommend to break down the problem and then try the solution in the Xcode playground.
The first thing they ask you to do is to create a constant called totalScore so you have to use let. Since you are using a constant, you have to increment the initialScore on the same line since you cannot change a constant later.
// Enter your code below var initialScore = 8 let totalScore = ++initialScore // increment before assignment by using ++
For step 2, you are declaring a winner if totalScore does not equal 10. In your case, that check is missing. It would look like this.
var initialScore = 8 let totalScore = ++initialScore initialScore let isWinner = totalScore != 10 // if totalScore is not equal to 10, you get true. Otherwise you get false
I hope that helps,
PS: If you found the above helpful, be sure to check out my app which breaks code challenges down and really explains things so you can learn Swift faster.
Code! Learn how to program with Swift
PPS: I could not have developed the above app without going through the awesome resources on Team Treehouse. Stick with it. It is so worth it!
Thank you so much, Mike! Trying to solve it in the Playground first really helped me break it down and understand it a bit better. I will definitely try your app. Thanks again!