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 trialRoderick Royce
1,236 PointsFunction's Challenge 3 / 3 Call the function greeting and pass it the string "Tom".
func greeting(String) { let person = "XYZZY" println("Hello (person)") }
greeting(Tom)
// the above is what I thought would work but it is not the right String parameter style. What am I missing?
func greeting(String) {
let person = "Tom"
println("Hello \(person)")
}
greeting("\(person)")
2 Answers
Chris Shaw
26,676 PointsHi Roderick Royce,
You're code is very close to what it needs to be, you simply have some of it in the wrong spot
Your function parameter is incorrect, a type of
String
on it's own is invalid. Instead it should beperson: String
You don't need to declare a constant called
person
within yourgreeting
function as that is the argument we're going to pass into itWhen calling your
greeting
function we should be passing the stringTom
into it as an argument.
func greeting(person: String) {
println("Hello \(person)")
}
greeting("Tom")
Happy coding!
Roderick Royce
1,236 PointsThank you Chris, you had the correct answer. I have only just begun and it is very difficult. Thank you for your support! C=
Chris Shaw
26,676 PointsYou're welcome, you're not the only one in that boat so ask as many questions on the forum as you desire. We're always here to help.
Jhoan Arango
14,575 PointsJhoan Arango
14,575 PointsHi Chris: Maybe you can help me answer my question ? Itβs on the Forum!
Thanks