JavaScript prüfen, ob die Nummer gerade oder ungerade ist
function solution(num) {
return num % 2 === 0 ? 'Even' : 'Odd'
}
Cautious Cockroach
function solution(num) {
return num % 2 === 0 ? 'Even' : 'Odd'
}
function isEven(value) {
return !(value % 2)
}
const number = 5; //The input number whatsoever, in this case '5'
//Using an if-else statement and the modulo operator
if (number % 2 === 0) {
console.log("even")
} else {
console.log("odd")
}
let arr = [1,2,3,4,5,6,7,8,9,10,11,12]
let odds = arr.filter(n => n%2)
console.log(odds)