Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics Swift Types Recap: Swift Types

I am having a very difficult time trying to figure out what the question is asking. Nothing I do works for answers.

I have had trouble with this whole section. I cannot get the constants to go together with the way the question wants me to put them together. I'm not sure what I am doing wrong because I am typing the code just as the video shows me.

types.swift
// Enter your code below
let firstValue = 2
let secondValue = 8

let product = "firstValue" * "secondValue"

"\(fisrtValue) times \(seondValue)"

product 
Benarge Igwe
Benarge Igwe
1,589 Points

I'm in the same section but on the interpolation section (earlier part that you), and I'm also stuck with a similar problem. You're a bit further ahead than me it seems. But i think the spelling of (fisrtValue) is what's throwing off your code. It won't connect to the "let" function if the spelling is wrong. Try to adjust that in the last section and see what happens. Oh and spelling of "seondValue" is also gonna need to be fixed.

-Ben

Ben,

I couldn't get the first interpolation section either.. I thought maybe at first some kind of glitch, but I think I am just not doing something right. Would be awesome if they had an "Example" tab, just to compare your answer with something that is right. But, thank you for pointing out my typo! haha I need to pay closer attention to that!

Benarge Igwe
Benarge Igwe
1,589 Points

Patrick,

Did it end up working? or are you still stuck on this challenge? Yeah I know it wasn't much help but we are just trying to progress at this app stuff. I hope you can get a reply soon regarding your question. I know how boring the waiting game is. sits at computer, waiting -_- lol

-Ben

Ben,

Watching the video over again. :( Always three steps forward and two steps back haha

Might have to take a break and come back, I HATE the waiting game! lol

2 Answers

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,258 Points

you assigned a number to product, not the result of multiplication. it's product = x * y, not product = (a number). your output string looks ok as long as you have the backslashes before the variables. they don't show up here if you don't escape them with a backslash so maybe you put them, i can't tell, for example here is one but i'm actually typing two \ . edit - your output string needs to say exactly word for word what they are asking for.

Finally! Thank you James! just had to add "the product of" into the interpolated string to get that right and now I understand product = x*y

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,258 Points

your string interp looks ok, just spell everything right, but product is not a string, it is the product of two integers, so it's just product = x * y. then make the string it asks you to with string interp, as in "\(myVar) is the best var, \(yourVar) is not..."


let firstValue = 2 let secondValue = 4

let product = 8

let output = "(firstValue) times (secondValue) is (product)"

I've tried this 10 different ways, I just don't know what the question is looking for exactly.

Here is what it is asking "Step 1: Declare a constant named product and assign the result of multiplying firstValue and secondValue together. (To multiply two values, a and b, we write a * b).

Step 2: 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."