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
This my code and it keep saying I have an error
var initialScore = 8 let totalScore = ++initialScore let isWinner = 10 != 10 let isWinner = totalScore != 10
// Enter your code below var initialScore = 8 let totalScore = ++initialScore let isWinner = 10 != 10 let isWinner = totalScore != 10
Rogier NitschelmiOS Development Techdegree Student 5,461 Points
I do not know the context of the assignment and if you have been exposed to loops and functions yet, but here are some things to help:
the initialScore should probably be the same value (0) in every case. If so, it might be a good idea to change the var into a let here.
if the totalScore is calculated more than once, you will have to change it from a constant to a variable. As the value stored is in that case subject to change. You could also consider dropping initialScore and just using 'var totalScore' to store the score at all times and set it to 0 initially.
let isWinner = 10 != 10 always results in false because 10 is equal to 10. Perhaps you want to compare the totalScore with the value 10?
var totalScore = 0 ... // some logics that adds points to the score like totalScore += 10 ... let isWinner = totalScore == 10 // true