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 2.0 Basics Swift Types String Manipulation

israelascencion
israelascencion
777 Points

I tried my code in Xcode and it works. let concatenatedGreeting = greeting + " " + name + " " + finalGreeting

What´s wrong?

strings.swift
// Enter your code below

let name = "Mick."
let greeting = "Hi there,"
let finalGreeting = "How are you?"

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

let concatenatedGreeting = greeting + " " + name + " " + finalGreeting

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Israel,

While your code is correct syntactically, it is not what the challenge has asked for. Challenges are very specific and very picky. You have assigned values to constants that are not what the challenge wants, and you have two extra ones that were also not asked for.

The first part of the challenge wants you to create only two variables (both constants). One called name with your name and another called greeting with an interpolated string.

So, the first part of the challenge will only have

let name = "Mick."
let greeting = "Hi there, \(name)"

Now the second part of the challenge wants you to concatenate the value of greeting with the string literal " How are you?" into a constant called finalGreeting.

let name = "Mick."
let greeting = "Hi there, \(name)"

let finalGreeting = greeting + " How are you?"

Hope that helps. Remember, you have to pay very close attention to what the challenge is asking for, as they are very picky. :)

:dizzy: