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

Cannot Complete the Concatenation Example

Trying to complete task 2 in the concatenation section. Code is attached.

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

1 Answer

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

Hi there, David Moore ! It looks like you're doing great and you were off to a great start. In fact, there are only two characters here stopping you from passing the second step. You have put quotation marks around "greeting" which means that it's no longer the variable greeting. It's literally the word greeting. At this point the value stored in finalGreeting is greeting How are you? instead of Hi there, David. How are you?

You wrote:

let finalGreeting = "greeting" + " " + "How are you?"

But you meant to write:

// note the removal of the quotation marks from greeting
let finalGreeting =  greeting + " " + "How are you?"

Now, that being said, you could even shorten that just a bit and instead put the space inside the last string like this:

let finalGreeting =  greeting + " How are you?"

Hope this helps! :sparkles: