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

What 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
Matthew Long
28,379 Points

First, 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!