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

Im not sure why it so not correct? I checked it in Xcode, and everything is ok

Im not sure why it so not correct? I checked it in Xcode, and everything is ok. Whats wrong with it:

let firstValue = 25 let secondValue = 78 let product = firstValue * secondValue let output = "("The product of ") (firstValue) ("times ") (secondValue) (" is ") (product)"

The task is :Using string interpolation, create a string literal that describes the operation we just performed. For example, given the following values for firstValue, secondValue and product respectively: 2, 4, 8. The string should read: "The product of 2 times 4 is 8". Assign this string to a constant named output.

6 Answers

Ian Billings
PLUS
Ian Billings
Courses Plus Student 7,494 Points

Hi,

I am not sure if it is how my browser is displaying it, so apologies if its the same, but the final line should look like:

let output = "The product of \(firstValue) times \(secondValue) is \(product)"

Ian thank you so much for the answer! I v got it!

Excuse me! Can you help me with one more challenge, because im stuck. And i dont understand task: Step 2: When value obtained using a remainder operator is 0, this means that the value is a perfect multiple of the divisor. Compare the value of result to 0 using the equality operator and assign the resulting value to a constant named isPerfectMultiple. https://teamtreehouse.com/library/swift-basics-2/swift-operators/working-with-operators should to check my let total with let someOperation and let anotherOperation should be like this: total == someOperation total == anotherOperation But i dont understand how should i create a new constant isPerfectMultiple - and what should i write inside? bool(true or false)?

Ian Billings
Ian Billings
Courses Plus Student 7,494 Points

Hi,

The remainder operator '%' gives you what is left after one number is divided by another. For example, when 4 is divided by 2, the remainder is 0, because 2 goes into 4 exactly 2 times. When 5 is divided by 2, the remainder operator returns one, because 2 goes into 5, 2 times but there is still 1 left over, if that makes sense? That means that the remainder function is useful for checking if a number is even or odd, as any number divided by 2, if the remainder is 0, must be even. So the first step, is asking you to calculate the remainder of value of divisor and store that in result:

let result = value % divisor

Then, using the equal comparison (==), check to see if result is equal to 0, if it is the constant will be true, if not false, so it will a boolean type.

let isPerfectMultiple = result == 0

Hope that makes sense.

Ian

Ian thank you so much again for your help! Now its clear for me

Ian please one more time, if you can In 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 anything but 10, you win. Declare a constant named isWinner and assign the results of a comparison operation to check whether the player has won or not. For example, if the total score is not 10, then the player has won and isWinner should equal true. (Hint: Use the NOT operator) I think like this and checked its ok in Xcode, but in Treehouse No and im breaking my brain during 2 hours about it: '''var initialScore = 8 initialScore += 1 if initialScore != 10 { let isWinner = true }'''

Ian i have already found the decision! Thank you so much for everything!