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

Concatenating the greeting string with a second string literal

I got through the interpolation task: let name = "Ruby" let greeting = "Hi there, (name)"

Now I need to declare a constant named finalGreeting, and concatenate the value of greeting with the string literal " How are you?".

Example: "Hi there, Ruby. How are you?"

I keep getting an error message! Can somebody please help!

// Enter your code below
let name = "Ruby"
let greeting = "Hi there, \(name)." 
let finalGreeting = "\(greeting) + How are you?"

1 Answer

james south
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

the plus sign doesn't go in the string. you have greeting, it already has a period in it. add a space and that's the end of the first string, then you put the plus, then the second string they ask for. so "string one" + "string two".

Thank you James....but it says I have to declare a constant called finalGreeting....I'm not sure that I am following your guidance above correctly as I continue to get an error message : (