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 trialAdam Blomberg
700 PointsWhat is wrong with my code? It works in Xcode
I did check this pice of code in Xcode and it prints out exactly what i'm asked for, nonetheless i don't pass the challenge
// Enter your code below
let name = "Adam"
let greeting = "Hi there, \(name)"
let finalGreeting = "\(greeting). How are you?"
4 Answers
Tobias Helmrich
31,603 PointsHey there Adam,
yes, actually your code is perfectly fine, good job! :) The only problem is that the challenge wants you to use concatenation instead of string interpolation for the second task. So if you concatenate the greeting with " How are you?" with a "+" it should work just fine.
Like so:
// Enter your code below
let name = "Adam"
let greeting = "Hi there, \(name)."
let finalGreeting = greeting + " How are you?"
I hope that helps! :)
joaquin encinas
262 PointsI was doing the same thing as adam, thanks tobias for your help. it makes sense now
Sam Katz
2,986 PointsAdd me in. I was doing the same thing. Treehouse is by far the best tutorial site. I'm sorry I ever doubted them.
Sam Katz
2,986 PointsUnfortunately, my code works fine in Xcode, and does not satisfy the compiler.
let name = "Chelsea" let greeting = "hey there, (name)" let FinalGreeting = greeting + " how are you?"
Tobias Helmrich
31,603 PointsHey there Sam,
good job until here! Firstly you don't have a backslash when you're trying to interpolate name. But maybe this is a formatting issue with the Forums. The problem why you're not passing the last task is that your "finalGreeting" constant is called "FinalGreeting", note that you wrote the "F" in uppercase.
You should write variable/constant names in Swift with camelCase where the first word starts with a lowercase letter. When the challenge is evaluated it checks for "finalGreeting" but can't find it because it's case sensitive and "FinalGreeting" is another constant. Also take care to write the strings exactly like the challenge wants you to as the challenges can be very picky about that.
// Enter your code below
let name = "Chelsea"
let greeting = "Hi there, \(name)."
let finalGreeting = greeting + " How are you?"
I hope that helps! :)
Adam Blomberg
700 PointsAdam Blomberg
700 PointsOh, now i understand, thank you!