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 trialRonald James
Courses Plus Student 463 Pointswhats wrong with my code?
I've tried everything and it still won't work. Whats wrong with my code?
let name = "Ronald"
let greeting = "Hi there"
let interpolatedGreeting = "(greeting) , (name)"
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! I feel like you might be stuck on step 1, but I'm not entirely sure. First, there is no instruction by the challenge to make a constant named interpolatedGreeting
, so you can safely remove that line. The greeting
variable should contain the string "Hi there, " and the interpolated value of the name
variable. We use a backslash and a set of parentheses to tell Swift to take whatever value is in that variable and put it where those parentheses are. So the solution to the first step would be:
let name = "Ronald"
let greeting = "Hi there, \(name)"
If you were to now print the value of greeting
, it would print out "Hi there, Ronald", because it is taking the value stored in name
and inserting it at that spot in the string.
Hope this helps!