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 trialClay Walter
1,821 PointsCannot figure out what makes this string invalid
Greeting is supposed to be an interpolated string that incorporates the following:
- "Hi there, "
- Constant named name
- "."
Any assistance would be much appreciated
// Enter your code below
let name = "Clay Walter"
let greeting = "\("Hi there"), \(name)\(".")"
1 Answer
Tobias Mahnert
89,414 PointsYou're very close. Check the answer below and if you have any further questions let me know
let name = "Clay Walter"
let greeting = "Hi there,\(name)."
Clay Walter
1,821 PointsClay Walter
1,821 PointsThanks so much!
MIchael Montoya
3,222 PointsMIchael Montoya
3,222 PointsCan you explain why the first answer was incorrect?
Tobias Mahnert
89,414 PointsTobias Mahnert
89,414 PointsHe uses the wrong syntax which throws an Error. If you want to incorporate strings which are declared to constants or variables incorporate into other strings, you have to use the syntax like in the example above. You can also declare hi there to a separate variable and incorporate two variables to pass the challenge. I'm sure there are also other ways to do it but sometimes the challenge only concentrates on one particular way to solve it. Below you have an example how to do it with two variables