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 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?

strings.swift
// Enter your code below
// Interpolated Greeting


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

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

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
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.

Hi!

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!