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 trialerinkrentz
8,839 PointsThis code is working in the Playground, but not in the challenge
The error says I'm using secondName instead of lastName
erinkrentz
8,839 Pointsstruct Person {
let firstName: String
let lastName: String
func getFullName (firstName: String, lastName: String) -> String {
return "\(firstName) \(lastName)"
}
}
Jake Adams
1,608 PointsYour solution is valid and a common practice, but that's not the pattern the lesson parser is looking for. See my answer below. Hope it helps!
erinkrentz
8,839 PointsHow can I skip the challenge?
Jake Adams
1,608 PointsWere you able to get through the challenge with my answer below?
1 Answer
Jake Adams
1,608 PointsYou need to use the instance properties of the Person struct
instead of passing arguments to the function.
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String {
return "\(firstName) \(lastName)"
}
}
-edit- replace original answer now that I saw the underlying issue
erinkrentz
8,839 PointsThis still doesn't work. Is there any way to skip the challenge?
struct Person {
let firstName: String
let lastName: String
func getFullName(firstName: String, lastName: String) -> String {
return firstName + " " + lastName
}
}
Jake Adams
1,608 Pointsah, I see the issue now. You are passing in arguments to the function when you should be using the instance properties. I totally missed that originally, so your original solution will work as long as you remove the function arguments.
Steven Deutsch
21,046 PointsSteven Deutsch
21,046 PointsHey Erin Krentz,
Can you post your code so that I can take a look? Maybe I can help, thanks.