re: Daily Challenge #81 - Even or Odd VIEW POST

FULL DISCUSSION
 

A Swift solution:

unc solution(_ numbers: [Int]) -> String {
    var odds = 0
    var evens = 0

    for number in numbers {
        if (number % 2 == 0) {
            evens += number
        } else {
            odds += number
        }
    }

    if (evens > odds) {
        return "Even is greater than Odd"
    } else if (evens < odds) {
        return "Odd is greater than Even"
    }

    return "Even and Odd are the same"
}
code of conduct - report abuse