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 trial
Asad Chishty
422 PointsI've typed out exactly what's specified but its coming up wrong. What's my mistake here?
I'm following the instructions exactly but I keep getting an error. What's the mistake here?
let name = "Asad"
let greeting = "Hi there, \(name)"
let finalGreeting = " How are you?"
let concatenation = "greeting" + "finalGreeting"
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! You're close here, but it doesn't exactly meet the specifications. So I'm going to give some hints because you are so close.
- This should only be three lines of code
-
greetingneeds to have a full stop/period at the end as indicated by the instructions in step 1 -
finalGreetingshould use concatenation of the variablegreetingalong with the string literal you currently have - the constant
concatenationis neither needed nor asked for by the challenge specifications
I think you can get it done with these hints, but let me know if you're still stuck!
Asad Chishty
422 PointsI got it!
It was
let finalGreeting = greeting + " How are you?"
Jennifer Nordell
Treehouse TeacherGood job! I was posting when you were posting yours But I'll leave my comment up for a breakdown for other students who might be looking for this answer.
Asad Chishty
422 PointsThanks so much, Jennifer!
I really appreciate your help :D
Asad Chishty
422 PointsAsad Chishty
422 PointsHi Jennifer,
I'm still not able to do it, I tried concatenation with each possible entry and it won't work.
I can't post a screen shot but the code I have is below.
let name = "Asad"
let greeting = "Hi there, (name)."
let finalGreeting = "greeting + name"
Isn't the last line using concatenation of the variable greeting and the string literal for my name?
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherIt's still not quite correct. First, you've removed the backslash in your string interpolation in the
greetingconstant. But you did add the full stop! And thefinalGreetingconstant is supposed to concatenate the variablesgreetingand the string literal " How are you?". Note the leading space before the word "How". But what you've done is assign a string literal of "greeting + name" to the `finalGreeting. Take a look:Here we set the
nameto the string literal "Asad". Then ingreetingwe assign the string"Hi there, \(name)". Because of the string interpolation here,greetingwill now hold the string "Hi there, Asad.". Then we createfinalGreetingand concatenate the string in ingreeting(as described in the previous sentence) and the string literal " How are you?". The end result will be thatfinalGreetingwill hold the string "Hi there, Asad. How are you?". Hope this clarifies things!