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 trialHarry Stebbings
1,097 Pointsfunc greeting("Hello", person: String) ->String { return } What should I add to this?
would be really grateful for the help!
func greeting("Hello", person: String) ->String {
return
}
2 Answers
Steve Hunter
57,712 PointsI think you're after ...
func greeting (person: String) -> String {
return "Hello, " + person
}
Then call the function and pass in the person
like:
greeting("Steve")
Will give you the output, Hello, Steve
.
Steve Hunter
57,712 PointsHiya,
Your answer is correct - but does the question ask for the output to be more than just firstName + lastName
. Are they separated by spaces, for example, or preceded by "Hello".
What's the question asking for?
Steve.
Harry Stebbings
1,097 PointsHarry Stebbings
1,097 PointsSteve, thank you so much. Worked like a dream. Just wondering if you could assist on the extra credit section of functions? This is the code I have but I am not sure if it was right, can you have a quick look? func fullName(firstName: String, lastName: String) ->String { return firstName + lastName }