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 Basics Swift Types Recap: Swift Types

code challenge recap swift types step 2

Having issues understanding step 2 of swift recap types, any help would be greatly appreciated

types.swift
// Enter your code below

let firstValue = 2

let secondValue = 4

let product = firstValue * secondValue 

let output = "The product of 2 times 4, \(8)"

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Your code will generate no errors in Xcode so it may be difficult to tell why exactly this is failing the challenge. The problem is in your output variable. You are hard-coding in the results. We need the output to reflect the values stored in firstValue and secondValue. Right now, those are set by the challenge and so they are hard-coded values. But imagine that you're developing some sort of calculator application. You would want those values to change to reflect what the user wants the first value and second value to be. Maybe this time they did put in 2 and 4. But maybe next time they'll put in 30 and 20. There's no way to know. Users are highly unpredictable.

So I'm going to give a hint here. You do need to use string interpolation but you need to print out the values stored in those variables. We do this with a backslash and a parentheses. It tells swift to put the value stored in that variable at that spot in the string.

var name = "Chris"
print("Hi there, \(name)")

You might try this in Xcode. You'll see that what prints to the console is "Hi there, Chris". I think you can get it with these hints, but let me know if you're still stuck! :sparkles:

thx

Thank you again for your response finally had time to sit down and figure it out your clues really helped.