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 trialRichard Parkins IV
1,970 PointsI can't figure out why this is failing. let finalGreeting = "\(greeting) How are you?"
I have no idea why this is not working.
// Enter your code below
let name = "Richard"
let greeting = "Hi there, \(name)."
let finalGreeting = "\(greeting) How are you?"
3 Answers
Angel Caro
11,831 PointsYou need to use string concatenation not interpolation, see below:
let finalGreeting = greeting + "How are you?"
Carl Smith
8,185 PointsThe reason is because you are using an "Interpolated" string instead of a "Concatenated" string for the finalGreeting. you need to make the code look like this.
let name = "Carl"
let greeting = "Hi there, (name)." //Interpolated because it is using a value from another string.
let finalGreeting = greeting + "How are you?" //Concatenated because it is adding them together (Notice the "+").
Hope this helps!
Angel Caro
11,831 PointsYou show your code by using 3 backticks ` followed by the language you are using, the code on the line below and three backticks below the code.
Richard Parkins IV
1,970 PointsThanks guys that fixed the problem. Sorry for the kinda stupid question lol
Angel Caro
11,831 PointsThere's no such thing as a stupid question, thats what where here for. Everyone is/was a beginner at some point.
Carl Smith
8,185 PointsCarl Smith
8,185 PointsHow do I show my code like that from the challenge?