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 trialAdrian Yao
1,002 PointsWhat is the problem with my code?
It asks me for concenatation and I think I did that with the greeting.
// Enter your code below
let name = "Adrian"
let finalGreeting = " greeting + How are you?"
let greeting = "Hi there, \(name),"
3 Answers
Alexander Davison
65,469 PointsA few things:
- Did you create the
finalGreeting
variable before defining thegreeting
variable? The variablegreeting
does not yet exist when you definefinalGreeting
, because you made thegreeting
after you made thefinalGreeting
variable. Try defining thefinalGreeting
variable after thegreeting
variable. - Why did you edit the
greeting
variable's text? The string was originally "Hi there, (name)", but you added a little comma after the\(name)
. Code challenges are extremely picky, so even a mere comma can cause a frustrating Bummer message. - You need to have the
greeting
variable outside of the quotes when concatenatinggreeting
and "How are you?" together. Instead of"greeting + How are you?"
it should begreeting + "How are you?"
.
I hope this helps
~Alex
Jeff McDivitt
23,970 Pointslet name = "Jeff"
let greeting = "Hi there, \(name)"
let finalGreeting = "\(greeting)" + "How are you?"
Alexander Davison
65,469 PointsYou shouldn't just give out an answer.
The best way to learn programming is to try fixing things on your own. If you just give out an answer, people won't really think how the answer is correct, and will only copy-and-paste the answer. If you explain what's wrong and don't provide the answer, you are allowing people to understand what's wrong. If you understand what's wrong, he will never make the mistake again.
Give a man a fish, feed him a day, teach the man to fish, feed him for a lifetime
Jeff McDivitt
23,970 PointsAlexander Davison - I agree in which I typically do I must have forgotten to paste the other code in their other than the actual code. Which I see you have taken care of