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 2.0 Basics Swift Operators Working With Operators: Part 2

Daquan Fudge
Daquan Fudge
1,879 Points

I'm confused on how to increment initialScore once if I'm suppose to declare totalScore as a constant.

I thought that I can simply add ++ to the assigned value of initialScore. The challenge keep saying increment the value of initialScore once. I;m not sure what I'm doing wrong.

operators2.swift
// Enter your code below

var initialScore = 8
let totalScore = ++initialScore
initialScore = ++initialScore


let isWinner = 10 != 10

2 Answers

Okay. You almost got it. The challenge is asking that you create a constant called isWinner, then assign the results of a comparison operation. It seems like in your code, you are assigning the incremented value of initialScore to totalScore (let totalScore = ++initialScore), then re-increment the value of initialScore again. That's where the error is coming from.

I believe you need something like this to solve your problem:

var initialScore = 8

let totalScore = ++initialScore

let isWinner = totalScore != 10 
Daquan Fudge
Daquan Fudge
1,879 Points

@MUZ141095 Thanks dude.