iOS Swift Basics Swift Types Recap: Swift Types

Sua Kim
Sua Kim
449 Points

I’m not sure how to make the code evaluate my values that I assigned to my constants

How am I Supposed to make the code evaluate the values?

// Enter your code below
let firstValue: Int = 2
let secondValue: Int = 3
let product = 6
let output = "The product of 2 times 3 is 6, \(firstValue * secondValue = product)" 

1 Answer

Jhoan Arango
Jhoan Arango
Treehouse Moderator 12,851 Points

Hello Sua:

You are doing good, sometimes it's difficult to grasp on the definitions and the "coding" talk, but you will get the hang of it as you go.

In this challenge we want to first create two constants and then we will multiply them.

let firstValue = 2
let secondValue = 6

let product = firstValue * secondValue // Multiplying both values

After we have done that, then we want to use string interpolation and assign it to another constant called "output".

let output = "The product of \(firstValue) times \(secondValue) is \(product)"

// By doing it this way you are not hardcoding the string, so you may use different values
// and you will always get the same sentence but with different "values".

This will give you the desired result.

Good luck, hope this helps.

Also remember to select best answers to help others know which answer has helped you solved and understand your problems.