iOS Functions in Swift Adding Power to Functions Returning Complex Values

Sebastian De Bruyne
Sebastian De Bruyne
3,832 Points

Code compiles perfectly in Xcode but does not pass the exercise

I have no idea why my code does not work for the exercize, it works perfectly on Xcode.

All I get is "Bummer make sure you are returning the correct values for each case statement".

Can anyone spot a mistake or tell me what the problem is with this code?

thanks a lot in advance for your attention and precious time spent helping me

functions.swift
// Enter your code belowlet result = getRemainder(value: 10, divisor: 3)

func coordinates (for location: String) -> (Double, Double) {
    var lat: Double = 0.000
    var lon: Double = 0.000

    switch location {

    case "Eifel Tower":  lat = 48.8582; lon = 2.2945
    case "Great Pyramid":  lat = 29.9792; lon = 31.1344
    case "Sydney Opera House": lat = 33.8587; lon = 151.2140
    default: return (0,0)

    }
    return (Double: lat, Double: lon)

}
var loc = coordinates(for: "Eifel Tower")

1 Answer

andren
andren
28,384 Points

You have misspelled "Eiffel Tower" as "Eifel Tower" in your code (two f's vs one). If you fix that typo like this:

func coordinates (for location: String) -> (Double, Double) {
    var lat: Double = 0.000
    var lon: Double = 0.000

    switch location {

    case "Eiffel Tower":  lat = 48.8582; lon = 2.2945 // Corrected Eifel to Eiffel 
    case "Great Pyramid":  lat = 29.9792; lon = 31.1344
    case "Sydney Opera House": lat = 33.8587; lon = 151.2140
    default: return (0,0)

    }
    return (Double: lat, Double: lon)

}

Then your code will pass.

Sebastian De Bruyne
Sebastian De Bruyne
3,832 Points

Thank you very much!! I spend the whole evening looking for a mistake and thinking it was reading a float rather than a double or trying different things that I didn't notice it was a spelling mistake.