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 trialJuan Munoz
2,146 PointsI dont understand what am I doing wrong
Please review my code I have tried this on xcode and it outputs the return value.
I also tried it with Tom but it says it tried returning Fred. then I tried it with Fred and it still doesnt work
func greeting(person: String) -> String {
return person
}
let person = greeting("Fred")
println("Hello \(person)")
2 Answers
William Li
Courses Plus Student 26,868 PointsHello, Juan, you should do everything within the function body.
The function should return a greeting. For example, if you pass in a string "Tom" then the return string would be: "Hello Tom".
func greeting(person: String) -> String {
return "Hello \(person)"
}
Juan Munoz
2,146 Pointsoh Wow I was getting ahead of myself, Thank you very much William Li