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 trialmanoj Singireddy
1,762 PointsFunctions in Swift
func coordinates(for location: String) -> ( Double, Double) { if location == "Eiffel Tower" { return (48.8582, 2.2945) } else if location == "Great Pyramid" { return (29.9792, 31.1344) } else if location == "Sydney opera House" { return (33.8587, 151.2140) } else { return (0,0) }
}
// Enter your code below
func coordinates(for location: String) -> ( Double, Double) {
if location == "Eiffel Tower" {
return (48.8582, 2.2945)
} else if location == "Great Pyramid" {
return (29.9792, 31.1344)
} else if location == "Sydney opera House" {
return (33.8587, 151.2140)
} else {
return (0,0)
}
}
4 Answers
Steve Hunter
57,712 PointsHi Manoj,
Sydney Opera House has a capital 'O'. Your code is fine if you change that.
But I'd suggest using a switch statement as it is neater:
func coordinates(for location: String) -> (Double, Double) {
switch location {
case "Eiffel Tower": return (48.8582, 2.2945)
case "Great Pyramid": return (29.9792, 31.1344)
case "Sydney Opera House": return (33.8587, 151.2140)
default: return (0, 0)
}
}
Steve.
manoj Singireddy
1,762 PointsI have tried both. Switch statement was fine but if else case was giving me an error. I have been checking over return values but havenβt checked location.
Steve Hunter
57,712 PointsYeah - the tests are very specific so are case sensitive - changing 'opera' to 'Opera' will fix your if/else
code.
manoj Singireddy
1,762 PointsThanq steve. It was great tutorials. Could you please suggest me some interview questions.
Steve Hunter
57,712 PointsWhat sort of interview? Are you leading the interview or are you the candidate?
manoj Singireddy
1,762 PointsIam the candidate.. what kind of questions do can i expect.
Steve Hunter
57,712 PointsI'd be asking questions about the job description - provide examples of how you can perform the tasks required, work as a team player, be a self-starter. Then I'd be asking questions about what the candidate knows about the business/company - why will they be a good fit; where do they see their career developing in the business. I'd be asking about the candidate's knowledge of the field the business operates in - how do they remain up to date with developments, how well known are they within the market, what contacts does the candidate bring, how will they be better connected in this role, why does the role represent a career progression, will the candidate's future plans move them away from the business?
Just some thoughts. I've not done interviews for a while but they usually focus on key competencies and then explore how the candidate's experience fits with the role/team/company.
I hope that helps.
Steve.