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 trialwalter fernandez
4,992 PointsIn this game of ours, we have an odd scoring mechanism . At the end of the round, if your score is 10, you lose! If it's
help.
// Enter your code below
var initialScore = 8
initialScore += 1
let iswinner = true
let iswinner != 10
9 Answers
David Lin
35,864 PointsYou almost got it ...
- You misspelled "isWinner"
-
isWinner
needs to be set equal to the conditionalinitialScore != 10
, because the conditional is what will betrue
orfalse
.
// Enter your code below
var initialScore = 8
initialScore += 1
let isWinner = initialScore != 10
Juno Jo
4,981 Pointsvar initialScore = 8 initialScore += 1 var totalScore = 10
let isWinner: Bool = totalScore >= initialScore
Juno Jo
4,981 Pointsvar initialScore = 8
initialScore += 1
var totalScore = 10
let isWinner: Bool = totalScore >= initialScore
walter fernandez
4,992 Pointsi have i question, because when i want to make a conversation like var karina = "Hi pedro, i need you today" var pedro = "Hi karina, yer tell me" karina var pedro = "are you joking?" i cannot because it says that i type pedro already how can i fix that?
David Lin
35,864 PointsWalter, don't re-declare w/ var again, just re-assign pedro directly:
var karina = "Hi pedro, i need you today"
var pedro = "Hi karina, yer tell me"
pedro = "are you joking?"
walter fernandez
4,992 Pointsthanks man, you are the best.
David Lin
35,864 Pointsyou're welcome! :-)
walter fernandez
4,992 Pointshello again i do not want to bother you but i try to tell karina that she is dumb and I ( pedro) will give a exercise to prove that but when i type pedro = 123 % 2 or var pedro = 123 % 2 or let pedro = 123 % 2 it appears like error could you help me?
walter fernandez
4,992 Pointshi i did that pedro = "are you joking?" karina = "i am not stupid" pedro = "yes you are, and also you do not know anything of math" pedro = "how much is 123 % 12 ? " karina = i want to know how karina can say that answer because if i type karina = 123 % 12 it appears like a error.
David Lin
35,864 PointsThat's because your variables were already inferred to be of string type. So any new value you later assign to them must also be string.
For example, try:
katrina = "\(123 % 12)"
or
let answer = 123 % 12
katrina = "That's easy! The answer is \(answer)."
Wrapping a non-string value inside \()
to make it a string is called string interpolation.
walter fernandez
4,992 Pointsthanks.
walter fernandez
4,992 PointsMy friend, if i want karina to say a wrong answer how can i do that if i already named her for example var karina = " hi" var pedro = "hello" // if i type karina == pedro // I know that it is going to be false, but after that i type pedro = "give me the answer" pedro = 2 + 2 // i want karina to reply wrongly and that it appears in my code as false.
David Lin
35,864 Pointshey Walter - sorry, I don't understand your question. For one thing, you wouldn't be able to assign pedro to both a string ("give me the answer") and an int (2+2) with the same var declaration. I didn't understand the rest of what you're trying to do.