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 trialBryce lind
144 PointsI don't understand how you would write the firstValue and secondValue to multiply each other.
I'm having trouble figuring out how to end up with the final string.
// Enter your code below
let firstValue = 56
let secondValue = 34
let product =
let output = "The product of"\(firstValue),"times"\(secondValue)"is"\(product)"
1 Answer
ianhan3
4,263 PointsYou never set the product constant to anything. It should be the firstValue multiplied by the secondValue
// Enter your code below
let firstValue = 20;
let secondValue = 10;
let product = firstValue * secondValue
let output = "The product of \(firstValue) times \(secondValue) is \(product)"
ianhan3
4,263 Pointsianhan3
4,263 PointsFor fun - a better way to do this in a project would be to set up a simple function that takes in two parameters and returns the product. This way you can reuse the function as many times as you want with different parameters.
ianhan3
4,263 Pointsianhan3
4,263 PointsFor fun - a better way to do this in a project would be to set up a simple function that takes in two parameters and returns the product. This way you can reuse the function as many times as you want with different parameters.
Bryce lind
144 PointsBryce lind
144 PointsThank you very much!