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 trialMahmoud Rajabzadeh-Mashhadi
489 PointsThis works in my laptop but not here in safari.
let name = "Beezhan." let greeting = "Hi there," let interpolatedGreetingName = "(greeting) (name)"
this has no error in my laptop xCode but it won't work here.
// Enter your code below
let name = "Beezhan."
let greeting = "Hi there,"
let interpolatedGreetingName = "\(greeting) \(name)"
2 Answers
Steve Hunter
57,712 PointsHi Mahmoud,
The test behind the challenge is looking for a constant named greeting
that contains the text, "Hi there, (name)." That's not what your code is producing, unfortunately.
One solution could look like:
let name = "Steve"
let greeting = "Hi there, \(name)."
The last stage of the challenge requires the greeting
constant again to use it in concatention so, again, the tests in the challenge will be making sure that the greeting
constant exists:
let name = "Steve"
let greeting = "Hi there, \(name)."
let finalGreeting = greeting + " How are you?"
It can help to remember that having something that works in Xcode and having something that passes the compiler's tests can be two different things. The question asks for specific constant names; your Xcode does not - it just ensures you are using correct syntax.
I hope that helps,
Steve.
Mahmoud Rajabzadeh-Mashhadi
489 Points@ Steve Hunter & Mike Me ... it works now. I appreciate your answers. Best Beezhan.
Steve Hunter
57,712 PointsNo problem - glad you got it fixed.
Steve.
Mike Me
5,148 PointsMike Me
5,148 PointsHi Mahmoud! Technically it should not cause any trouble. But I think you better use: let interpolatedGreetingName = greeting + name Which is equivalent to "Hi there,Breezhan", and if you want some space for readability just add it after comma in "Hi there, ". The reason why it did not work here, most likely tutors want you to be good coder so you will be able write clean and good(right) code.