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

iOS Swift Basics Swift Operators Working With Operators: Part 2

I am confused on the Code Challenge! Swift 3: In this game of ours ...

var initialScore = 8

initialScore += 1

let isWinner = totalScore != 10

operators.swift
// Enter your code below

var initialScore = 8

initialScore += 1

let isWinner = totalScore != 10

2 Answers

David Papandrew
David Papandrew
8,386 Points

Corrected code:

var initialScore = 8
initialScore += 1
let isWinner = initialScore != 10

Explanation:

First line sets initialScore to an Int value of 8

Second line adds 1 to the intialScore. Value is now 9

Third line: the statement to the right of the = sign is returning a boolean value. It effectively asks: True/false -- initialScore does not equal 10? The result of this comparison is true because initialScore currently equals 9. isWinner is currently set to a value of "true"

Hello David!

Thank you so much for the answer! Now I know why it didn't work. I appreciate your help!

Have a great day!