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.
Aryaman Dhingra3,536 Points
String Interpolation in Swift not working!!
I'm not too sure why this isn't working. I'm very new to Swift so, please help.
let firstValue = 10 let secondValue = 15 let product = firstValue * secondValue let output = "The product of \(String(firstValue)) and \(String(secondValue)) is \(product)" // Enter your code below
Although it does not draw an 'incorrect' response it is still unnecessary to place String before the constant. The goal is to always omit unnecessary words from your code unless it is necessary for readability. You just need to change 'and' to 'times'.
let output = "The product of \(firstValue) times \(secondValue) is \(product)"
Damien Watson27,419 Points
Hey, your answer is really close, there is just one word in the output incorrect 'times', not 'and'. I dont think you need to wrap in the 'String()' either.
let firstValue = 10 let secondValue = 15 let product = firstValue * secondValue let output = "The product of \(String(firstValue)) times \(String(secondValue)) is \(product)"