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 trialbindipatel
Courses Plus Student 793 PointsWhat am I doing wrong with let output =
Sorry I need help. Not understanding why I am not getting let output right.
Thank you
// Enter your code below
let firstValue = 2
let secondValue = 4
let product = 2 * 4
let output = "\(product)", "\(firstValue)" * "\(secondValue)"
1 Answer
Matthew Long
28,407 PointsFirst, the value for product
is wanting you to multiple the constants firstValue
and secondValue
together instead of rewriting those values. Also, the syntax for your string interpolation is a little messed up. You may to be trying to combine string concatenation and interpolation? I say this because you only need one set of quotes. Also, the output should read "The product of 2 and 4 is 8" where yours reads something closer to "8, 2 * 4". Yours actually won't compile, but if you fixed your quotes it would still not be what the challenge is looking for. You can click the preview button and it will give you a good idea of where your error is happening!
let firstValue = 1
let secondValue = 2
let product = firstValue * secondValue
let output = "The product of \(firstValue) times \(secondValue) is \(product)"
Note that it is possible to do math operations inside string interpolation like you seem to have attempted. However, it has to be inside the parentheses.
let output = "The product of \(firstValue) times \(secondValue) is \(firstValue * secondValue)"
Keep up the hard work!