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 trialMark Cai
1,505 PointsChallenge 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?"
1 Answer
David Papandrew
8,386 PointsStep 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
Craig Allen
12,388 PointsCraig Allen
12,388 PointsIn 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?"