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 trialAlex Nelsen
Courses Plus Student 2,977 PointsI need help solving this code challenge.
I have tried this numerous ways, and this seems to work in my playground but does not work in the code challenge. Any help would be appreciated!
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String{
return "\(firstName) \(lastName)"
}
}
let aPerson = Person(firstName: "Alex", lastName: "Nelsen")
aPerson.getFullName()
2 Answers
Steven Deutsch
21,046 PointsHey Alex Nelsen,
You need to assign the value you are returning from your call of getFullName to a constant called fullName.
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String{
return "\(firstName) \(lastName)"
}
}
let aPerson = Person(firstName: "Alex", lastName: "Nelsen")
let fullName = aPerson.getFullName()
Good Luck
Alex Nelsen
Courses Plus Student 2,977 PointsThat worked great. I appreciate all your help today!
Steven Deutsch
21,046 PointsNo problem :)
Charlotte S
829 PointsCharlotte S
829 PointsCould someone explain why this needs to be done to complete the code challenge but not in playground?