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 trialCarson Carbery
9,876 PointsWorks in playground but not in code challenge screen
Once again a code challenge that works fine in playground but not in the Code Challenge screen.. many thanks for any help.
Btw I am following the Swift 2.0 course and am having so many issues with the Code Challenge screen for this track that I'm thinking of Switching to the other Swift track. Does anyone have any experience of this course are the examples and challenges more constant and better structured. Btw I'm not a newbee to TreeHouse and have never had these issues with other courses.
// Enter your code below
func getTowerCoordinates(location: String)-> (long: Double, lat: Double) {
var longAndLat: Double = (0,0)
switch location {
case "Eiffel Tower": longAndLat = (48.8582, 2.2945)
case "Great Pyramid": longAndLat = (29.9792,31.1344)
case "Sydney Opera House": longAndLat = (33.8587, 151.2140)
default: longAndLat = (0,0)
}
return longAndLat
}
1 Answer
Michael Reining
10,101 PointsHi Carson,
You are close but there are a few things in your code that are problematic.
Just return two Doubles. Not sure why but if you try to name them it causes problems in the code challenge
Inside your function, your declaration for longAndLat was wrong
I think you are mixing up longAndLat (the names should be the other way around but it works either way)
See code below
// Enter your code below
func getTowerCoordinates(location: String)-> (Double,Double) { // return Tuple with two Doubles
var longAndLat = (0.0,0.0) // make it a Tuple that contains Doubles
switch location {
case "Eiffel Tower": longAndLat = (48.8582, 2.2945)
case "Great Pyramid": longAndLat = (29.9792,31.1344)
case "Sydney Opera House": longAndLat = (33.8587, 151.2140)
default: longAndLat = (0,0)
}
return longAndLat
}
I hope that helps,
Mike
PS: If you found the above helpful, be sure to check out my app which breaks code challenges down and really explains things so you can learn faster.
Code! Learn how to program with Swift
https://itunes.apple.com/app/code!-learn-how-to-program/id1032546737?mt=8
PPS: I could not have developed the above app without going through the awesome resources on Team Treehouse. Stick with it. It is so worth it!