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 trialandrew naeve
11,503 Pointssimple concatenation works in playground, not treehouse??
not sure why i can't pass this quiz. playground in xcode reads "Hi there, Andrew. How are you?" just fine, but no love on treehouse?
// Enter your code
let name = "Andrew"
let greeting = "Hi there, \(name)."
let finalGreeting = "\(greeting) How are you?"
1 Answer
razmig pulurian
Courses Plus Student 23,889 PointsHi Andrew,
Xcode won't give you an error because you wrote perfectly valid code. However, you cannot pass the challenge with this code because you are using string interpolation while the challenge asks you to use string concatenation. I used to get these confused all the time myself.
String interpolation uses the following notation, placed within a string literal:
\()
String concatenation uses the addition operator to add two independent strings together:
+
When you enter the code you posted above, you should see an message saying "Bummer! Make sure you're using concatenation to create the final string value required!"
Try using the following answer instead:
let finalGreeting = greeting + " How are you?"
Hope this helps explains things.