Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?

types.swift
// 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

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.