Javascript Check if number is even or odd
function solution(num) {
return num % 2 === 0 ? 'Even' : 'Odd'
}
Javascript Check if number is even or odd
function solution(num) {
return num % 2 === 0 ? 'Even' : 'Odd'
}
javascript check if a number is even or odd
const isEven = num => num % 2 === 0;
console.log(isEven(2));
// Result: True
javascript is number even or odd
// vanilla
function isEven(num) {
return num % 2 == 0;
}
function isOdd(num) {
return Math.abs(num % 2) == 1;
}
// ES6
const isEven = num => ((num % 2) == 0);
//bitwise AND operator
const isOdd = function(num) { return num & 1; };
const isEven = function(num) { return !( num & 1 ); };
odd or even js
for(let count =0; count<=100;count++){
count%2==0? console.log(`${count} is even`):console.log(`${count} is odd`);
;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us