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 trialCruiz Thomason
1,085 PointsHaving a hard time trying to figure out that last part of this question? I don't know how else to write it...
let interpolatedGreeting = "(greeting), (name)" this isn't right but I thought that would be and don't know how else it wants me to write it out.
// Enter your code below
let name = "Cruiz"
let greeting = "Hi there"
11 Answers
Andrew Warner
4,144 Pointslet greeting = "Hi there, \(name)."
Andrew Warner
4,144 PointsYou can use string interpolation to write out the greeting. Looks like you are missing the \ which is found on the keyboard above the return key. Try:
let name = "Cruiz" let greeting = "Hi there" let interpolatedGreeting = "\(greeting), \(name)"
Cruiz Thomason
1,085 PointsI have tried this but still seems to pop up as wrong and not sure why.
Andrew Warner
4,144 PointsMake sure that each statement is on a separate line. Also make sure you are using \ instead of /
if that isn't working make sure to reread the question and that you are following the instructions exactly. Often times you can be missing simple details
Cruiz Thomason
1,085 Pointslet name = "Cruiz" let greeting = "Hi there" let interpolatedGreeting = "(greeting), (name)"
This is exactly how I have it written out
Cruiz Thomason
1,085 PointsThis is the question that goes along with my answer:
In this task we're going to declare two strings. First, declare a constant named name and assign to it a String containing your name.
Second, declare a constant named greeting. Set the value of greeting to an interpolated string that combines "Hi there, " with the string stored in the name constant.
As an example, the final value of greeting could be "Hi there, Linda".
Andrew Warner
4,144 PointsBased on the question you need to:
let name = "Cruiz"
let greeting = "Hi there \(name)."
Looks like you made an extra variable. What you did technically works but isn't answering the question how it is assigned. They ask you to interpolate the value for greeting.
Cruiz Thomason
1,085 Pointslet name = "Cruiz"
let greeting = "Hi there (name)."
this is still showing as wrong.
Cruiz Thomason
1,085 Pointsand I don't know why when I post this it's taking out the forward slash .
Andrew Warner
4,144 Pointstry adding a comma. I noticed that too. I've been using two forward slashes and it seems to appear as one
Cruiz Thomason
1,085 Pointshaha. That finally worked. Thanks for your help!
Cruiz Thomason
1,085 Points// Enter your code below let name = "Cruiz"
let greeting = "Hi there, (name)"
let finalGreeting = "How are you?"
I'm suppose to concatenate the final line. How else do I do that?
Andrew Warner
4,144 Points"Hi there, \(name) \(finalGreeting)" - If there is a comma after the name make sure to add it "Hi there, \(name), \(finalGreeting)"