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.
Andrew Collazo124 Points
let name = "Andrew" let greeting = "Hi there, \(name)" let finalGreeting = "\(greeting), How are you?" whats wrong?
i keep writing this code
let name = "Andrew" let greeting = "Hi there, (name)" let finalGreeting = "(greeting), How are you?"
and it says im doing it correct on xcode but on teamtreehouse excersise its saying im wrong... please respond to me i never got a response last time.
let name = "Andrew" let greeting = "Hi there, \(name)" let finalGreeting = "\(greeting), How are you?"
The problem is that you use string interpolation (merging variables into strings using
\()) instead of string concatenation, which is what the task explicitly asks you to use.
With string concatenation you combine strings and variables by using the
+ operator. Both of these techniques where covered in the video preceding this challenge, and while they both result in the same string this task is specifically setup to test your knowledge of string concatenation and therefore only accept your code if you use that technique.
So to sum up you have to combine the
greeting variable and the " How are you?" string using the + operator, and not use
\() at all for the
finalGreeting value in order to pass this challenge.