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 trialDenonte McKinney
315 PointsI'm typing the same code into my xCode and it comes out as "Hi there, Denonte". Why doesn't it work in the template?
// String Concatenation let greeting = "Hi there" let name = "Denonte"
// String Interpolation let interpolatedGreeting = "(greeting), (name)"
// String Concatenation
let greeting = "Hi there"
let name = "Linda."
// String Interpolation
let interpolatedGreeting = "\(greeting), \(name)"
2 Answers
Matthew Long
28,407 PointsThere are many ways you can arrive to a solution, but often times Treehouse is looking for something very specific. For example, the task wants you to use string interpolation in the greeting
constant. Instead, you created a new constant that Treehouse wasn't expecting:
let name: String = "Linda"
let greeting = "Hi there, \(name)."
As a note, your comment says "string concatenation", but you never actually did any string concatenation. String concatenation is when you add two strings together. For example:
let name: String = "Linda"
let greeting: String = "Hi, "
let fullGreeting: String = greeting + name + "."
// Hi, Linda.
Also, for task two keep an eye out for string concatenation as well as string interpolation. It wants you to use string concatenation and string interpolation together. Many people don't see these instructions the first time through and forget to use string concatenation.
Denonte McKinney
315 PointsI tried the code a bunch of times and different times but it still didn't work. Theres a special requirement from the "finalGreeting" that i'm not meeting and I don't know whats the issue. :(
Matthew Long
28,407 PointsHmm maybe there's an issue? Whats your new code? The following works for me
let name = "Linda"
let greeting = "Hi there, \(name)"
let finalGreeting = "\(greeting)." + " How are you?"