Swift - Write program to extract only the odd numbers from the array

Requirements

Write program to extract only the odd numbers from the array

Demo

var numbers = [5,6,3,2,4,8,1,0]

var oddNumbers = numbers.filter (
    {// www .  ja va 2s  .c  o m
         (num: Int) -> Bool in
            num % 2 == 1
    }
)
print(oddNumbers)//[5, 3, 1]

Result

Related Exercise