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 trialDawson Young
512 PointsThe string literal being assigned to output must be an interpolated string that evaluates firstValue, secondValue and pr
I am suppose to write interpolated string that says something but its not working UGH. My current code is: let firstValue = 4 let secondValue = 5 let product = firstValue * secondValue let output = "("The product of 4 times 5 is") (product)"
// Enter your code below
let firstValue = 4
let secondValue = 5
let product = firstValue * secondValue
let output = "\("The product of 4 times 5 is") \(product)"
3 Answers
Tobias Helmrich
31,603 PointsHey Dawson,
Phillip already gave you a hint. You can interpolate variables in a string by writing them inside of \()
. You did that correctly with product, now you just have to do the same with firstValue and secondValue and not with the string around them.
Like this:
// Enter your code below
let firstValue = 4
let secondValue = 5
let product = firstValue * secondValue
let output = "The product of \(firstValue) times \(secondValue) is \(product)"
Phillip Paik
7,450 PointsThe output should be: "The product of (firstValue) times (secondValue) is (product)"
( blah blah) Only variables and arrays and constants or math should go inside the "blah blah" For regular strings, you keep that outside of them.
Dawson Young
512 PointsThank you Phillip Paik and Tobias Helmrich! I understand now thanks to you two awesome dudes
Tobias Helmrich
31,603 PointsNo problem! :) I'm glad you understand it now!