Welcome to the Treehouse Community
Looking to learn something new?
whats wrong with my code?
why is this wrong?
// Enter your code below let name = "Russ" let greeting = "Hi there, " let interpolatedGreeting = "(greeting) (name) (.)"
// Enter your code below let name = "Russ" let greeting = "Hi there, " let interpolatedGreeting = "\(greeting) \(name) \(.)"
Brian Merwin1,239 Points
The code is incorrect because the period you're trying to insert into the tail end of the "interpolatedGreeting" constant does not need to be included into the escape characters \( ) - those are only for inserting constants or variables into the new string. You can instead just enter the period as is like so:
let interpolatedGreeting = "\(greeting) \(name)."
The challenge is looking for certain things. First, a constant called
name that contains a string and, second, a constant called
greeting that contains the words "Hi there, " and then an interpolated insertion of the
It's not looking for a constant called
interpolatedGreeting so that's why your code isn't passing the challenge. A solution to the first part of this challenge could look something like:
let name = "Steve" let greeting = "Hi there, \(name)."
I hope that helps - let me know how you get on.