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 trialadnan ahmed
263 PointsDeclare a constant named isWinner and assign the results of a comparison operation to check whether the player has won o
What is the code for this what I have currently inputted does not work.
// Enter your code below
var initialScore = 8
initialScore += 1
var initialScore = 8
initialScore += 1
isWinner != totalScore == 10
isWinner = false
1 Answer
Thomas Dobson
7,511 PointsHi adnan,
First off take a look at my notes in your code:
// Enter your code below
var initialScore = 8
initialScore += 1
var initialScore = 8 //duplicate
initialScore += 1 //duplicate
isWinner != totalScore == 10 //your statement reads isWinner does not equal totalscore isequal to 10. You also used a new variable totalScore... which was not previously defined or needed.
//You also need to define isWinner with a let statement.
isWinner = false // set is winner to false...
Here is how it should look:
// Enter your code below
var initialScore = 8
initialScore += 1
let isWinner = initialScore != 10
// The above statement reads... set the constant of isWinner to the boolean result of initialScore does not equal 10.
// in this case 9 does not equal 10, which returns true. Constant isWinner is set to true.
I would recommend re-watching your videos on operators. You want to be sure to have a good grasp on these concepts before moving forward.
Also check out Apple's Operator Docs