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 trialJohn Henry Dale
360 PointsI'm having trouble with the swift types quiz, can someone please chime in ?
I've tried to do what the instructions ask and can't seem to get a proper result. Specifically I'm not sure where / how the string assigned to output "The product of 2 times 4 is 8" is supposed to be declared
// Enter your code below
let firstValue = 2
let secondValue = 4
let product = "\(firstValue) * \(secondValue)"
let output: String = "The product of 2 times 4 is 8"
1 Answer
Tobias Helmrich
31,603 PointsHey there,
firstly you don't have to use interpolation when calculating the product, just multiply the two values. The problem with your output constant is that you're just writing the numbers inside of the String manually but you have to use String interpolation, like you did in the product constant, so that the output changes depending on the values.
This is a working example:
// Enter your code below
let firstValue = 2
let secondValue = 4
let product = firstValue * secondValue
let output: String = "The product of \(firstValue) times \(secondValue) is \(product)"
If you have further questions feel free to ask, good luck! :)
eliasaidoukovitch
1,649 Pointseliasaidoukovitch
1,649 Points//have to do it like this
let firstValue = 2 let secondValue = 4 let product = firstValue * secondValue let output: String = "The product of (firstValue) times (secondValue) is (product)"