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 trialtroy cardona
96 PointsI cant figure out the code for this challenge
cna u help
// Enter your code below
let name = "Troy"
let greeting = "Hi there, \(name),"
let finalGreeting = "\(greeting), How are You?"
1 Answer
Matthew Long
28,407 PointsYou've almost got it except for a couple things. First off, you're using a comma after the greeting
in the finalGreeting
instead of a period. Often times these challenges are picky and are looking for something very specific.
The main issue is that the second challenge has asked you to use string concatenation whereas you only used string interpolation. I prefer using string interpolation wherever possible, but you must use string concatenation at least once for this challenge. There are a number of solutions that will get the challenge to pass.
The following are correct solutions (among other):
let name = "Troy"
let greeting = "Hi there, \(name)"
let finalGreeting = "\(greeting)." + "How are You?"
let name = "Troy"
let greeting = "Hi there, \(name)"
let finalGreeting = greeting + ". How are You?"
The following, will not pass, because it does not use string concatenation:
let name = "Troy"
let greeting = "Hi there, \(name)"
let finalGreeting = "\(greeting). How are You?"