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 trial

iOS Swift 2.0 Basics Swift Types Recap: Swift Types

Bryce lind
Bryce lind
144 Points

I 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.

types.swift
// Enter your code below
let firstValue = 56
let secondValue = 34
let product = 
let output = "The product of"\(firstValue),"times"\(secondValue)"is"\(product)"

1 Answer

You 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)"

For 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.

func multiply(firstValue, secondValue) {
return firstValue * secondValue
}

let product = multiply(20, 10)

For 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.

func multiply(firstValue, secondValue) {
return firstValue * secondValue
}

let product = multiply(20, 10)
Bryce lind
Bryce lind
144 Points

Thank you very much!