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 trialNorlan Tibanear
Courses Plus Student 722 Pointscan't move forward in the course
not sure what is wrong in the code. seems to work in my platform.
let name = "Norlan" let interpolationGreeting = "("Hi there"), (name)"
// Enter your code below
let name = "Norlan"
let interpolationGreeting = "\("Hi there"), \(name)"
Greg Kaleka
39,021 PointsCynthia, single quotes will not work. You'll get a syntax error. Norlan's current code actually does work as-is, but just because it works doesn't mean it's right . There's no reason to interpolate a string literal into a string - it already is one!
4 Answers
Greg Kaleka
39,021 PointsHi Norlan,
You only need the \() syntax to include variables/constants or calculated values. You shouldn't put the actual string part in parens:
// Enter your code below
let name = "Norlan"
let interpolationGreeting = "Hi there, \(name)"
I recommend re-watching this video about string interpolation earlier in the course.
Angel Caro
11,831 PointsYou don't need to encapsulate the "Hi there, " as this is part of the string only encapsulate the name like so:
let greeting = "Hi there, \(name)."
Anjali Pasupathy
28,883 PointsYou don't need to interpolate "Hello, there". You also need to assign the String to a constant called greeting (not interpolationGreeting), and you need to put a "." at the end.
let greeting = "Hi there, \(name)."
I hope this helps!
Norlan Tibanear
Courses Plus Student 722 PointsThank you everyone.
Anjali Pasupathy
28,883 PointsYou're welcome! (:
Cindy Lea
Courses Plus Student 6,497 PointsCindy Lea
Courses Plus Student 6,497 PointsTry using single quotes for Hi there