JavaScript memeriksa apakah nomornya bahkan atau ganjil
function solution(num) {
return num % 2 === 0 ? 'Even' : 'Odd'
}
Cautious Cockroach
function solution(num) {
return num % 2 === 0 ? 'Even' : 'Odd'
}
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")
}
const isEven = num => num % 2 === 0;
console.log(isEven(2));
// Result: True