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 trialSteven Matthews
186 Pointsinterpolation
hello,
I am stuck on the first interpolation question, my answer states:
let name = "Steve Matthews"
let greeting = "Hi there, " + name
please help
// Enter your code below
let name = "Steve Matthews"
let greeting = "Hi there, " + name
2 Answers
Eli Flores
iOS Development Techdegree Student 3,851 Points// LETS DO SOME SAMPLE: let name = "Jhon Doe"
STRING CONCATENATION:
let greeting = "Hi there, " + name // heavily uses the plus sign => " + "
STRING INTERPOLATION: let greeting = "Hi there, (name)" // Uses " ONE SET OF DOUBLE QUOTATION!", No need for the plus sign, "+" // but uses a special syntax ==> () <== // store the given properties either let or var between the parenthesis => (name)
Paul Karim
3,428 PointsHey Steven, so what you're doing is actually called String concatenation. The challenge requires string interpolation.
So you would do something like this
let name = "Paul Karim" let greeting = "Hi there, (name)."
In front of (name) you need a backslash :) but that's it.
Steven Matthews
186 PointsThank you for your help. I tried entering the code the way you typed it with the back slash but it still didn't work.
Steven Matthews
186 Pointsnever mind, I figured out what I was doing wrong, thanks again.