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 trialGiovanni Rinaldi
1,104 PointsI don't know how to do interpolation for the step 2. Please help me Giovanni
I need help in string interpolation for the constant output. Thanks
Giovanni
// Enter your code below
let firstValue: Int = 4
let secondValue: Int = 6
let product = firstValue * secondValue
2 Answers
Chase Marchione
155,055 PointsHi Giovanni,
We're told to create a constant called output. Since you've already made three constants, you know how to do that, so that's a good start!
The challenge asks us to make the output constant's value equal to a string containing something similar to 'The product of 2 times 4 is 8'--but instead of using those numbers, we need to use the constants that we just declared and initialized. We can print out the values of those constants through a process called interpolation, using the () syntax. Inside of the parentheses we would put the name of the particular variable/constant/etc.:
let output = "The product of \(firstValue) times \(secondValue) is \(product)"
Thus, given our constants' values, printing this out would produce "The product of 4 times 6 is 24."
Hope this helps!
Giovanni Rinaldi
1,104 Pointsit works, thanks ?????
Giovanni Rinaldi
1,104 PointsGiovanni Rinaldi
1,104 PointsI'll try it now. Thanks for your kind reply. I'm totally beginner in coding ?
Giovanni