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

Mark Cai
Mark Cai
1,505 Points

Challenge Task 2 of 2 is broken. The code works good when tested in actual playground.

Challenge is broken. My code works fine in playgrounds. There's probably an issue with the "Check Work" button

// Enter your code below

let name = "Mark"
let greeting = "Hi there, \(name)"

let finalGreeting = "\(greeting).  How are you?"
Craig Allen
Craig Allen
12,388 Points

In the last line they want you to separate the quotes. Close the first quote after the greeting and use the plus operator, then open then second sentence with a new quote. Adding a space in between isn't necessary but it will work either way.

let finalGreeting = "(greeting)." + "How are you?"

1 Answer

David Papandrew
David Papandrew
8,386 Points

Step 2 wants you to use string concatenation. You are using string interpolation. This is why it is not passing.

Concatenation is when you use the + operator to combine two or more strings.

Here is the corrected code (it will pass):

let name = "Mark"
let greeting = "Hi there, \(name)" //interpolated string
let finalGreeting = greeting + "How are you?" //concatenated string