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!

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 String Manipulation

Marie Michaud
Marie Michaud
233 Points

My code is coming out correctly in xcode but not in the browser. I dont understand what I am doing wrong.

My code appears to be correct when I put it in XCode but not in the browser. I can't see where I am missing anything and I have rewatched the video a few times. Could someone point out where I am making the mistake?

// Enter your code below
// Interpolated Greeting

let name = "Marie."
let greeting = "Hi there,"

let interpolatedGreeting = "\(greeting) \(name)"

2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

The problem lies in the interpretation of the instructions. Your greeting variable should be using interpolation with the name variable at the end. Also it needs a full stop. The last variable is supposed to be named finalGreeting and use concatenation... not interpolation. Yours is named interpolatedGreeting and uses interpolation. Give it a new try with these tips in mind :smiley:

:information_source: Even if your code is functional, the challenge can still fail if you do not follow the challenge instructions to the letter.


It is because the greeting var had to be interpolated string

you could do something like:

let name:String = "Marie."
let greeting = "Hi there, \(name)"

and that would work, the reason your code wasn't correct in the code challenge was because the greeting variable wasnt interpolated

I hope this helped!