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 trialLes Gaw
4,752 PointsNot sure why this second part did not work ?
I am not sure why the code did not work when i tried it as it appeared to work in Xcode?
// Enter your code below
let name = "Pasan"
let greeting = "\("Hi there,") \(name) \(".")"
let finalGreeting = "\(greeting) \(" How are you?")"
3 Answers
Alexander Davison
65,469 PointsYou don't need () for text inside of strings (although it is possible to use it and you still would be able to pass the challenge, the code would be hard to understand and fix). You only need it for variables/constants :)
Try this:
// Enter your code below
let name = "Pasan"
let greeting = "Hi there, \(name)."
let finalGreeting = "\(greeting) How are you?"
Also, you have an extra space before the period (code challenges are super picky, keep that in mind )
Good luck! ~Alex
Les Gaw
4,752 PointsThe error is "Make sure you're using concatenation to create the final string value required!"
Alexander Davison
65,469 PointsTry changing the period to a comma :)
~alex
Les Gaw
4,752 Pointsit turns out i messed up as i should have used string concatenation in the last part rather than just having a single string. Passed the test now. Thanks for your help
Alexander Davison
65,469 PointsNo problem :)
Les Gaw
4,752 PointsLes Gaw
4,752 PointsThanks Alexander - that has made it clearer for me in terms of not having to use additional quotations and () for text. However, using it in the code challenge the second part still shows an error! I am convinced i have typed this word for word and i know that it works in Xcode as per what you types. Thanks for your help though.
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsWhat's the error?