I have an array of numbers typed Int
.
I want to loop through this array and determine if each number is odd or even.
How can I determine if a number is odd or even in Swift?
var myArray = [23, 54, 51, 98, 54, 23, 32];
for myInt: Int in myArray{
if myInt % 2 == 0 {
println("\(myInt) is even number")
} else {
println("\(myInt) is odd number")
}
}