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 trialSterling J. Douglas
173 PointsDeclare a constant named finalGreeting, and concatenate the value of greeting with the string literal " How are you?"
My code is correct in xcode but the treehouse program is not accepting it? Help:
// Enter your code below
let name = "Pasan"
let greeting = "Hi there"
let interpolatedgreeting = "\(greeting),\(name)."
let finalGreeting = "How are you?"
let concatenatedGreeting = (greeting) + ","+name+"."+(finalGreeting)
1 Answer
Ben Masel
2,004 PointsHi there, Sterling! Now you've almost got it. Now string concatenation is when you stick something together. In swift it's when you close a string with a quotation mark then do a + then do antoher set of quotation marks. For e.g
let firstName = "Sterling"
let greeting = "Hello there, Sterling." + "How are you?"
So your thing should look something like this:
// Enter your code below
let name = "Pasan"
let greeting = "Hi there, \(name)."
let finalGreeting = "\(greeting)" + "How are you?"
If this doesn't work just comment and i'll help. Good luck!
Ben Masel
2,004 PointsBen Masel
2,004 PointsIn a minute...