0
Q:

check if number is even javascript

if ( num % 2 == 0) {
	alert('Even Number');
}else{
	alert('Odd Number');
}
2
function isOdd(num) { return num % 2;}
console.log("1 is " + isOdd(1));
console.log("2 is " + isOdd(2));
console.log("3 is " + isOdd(3));
console.log("4 is " + isOdd(4));
3
if ( n % 2 == 0 ) {
	// n is even
}
else {
	//otherwise odd
}
0
function evenOrOdd(num) { //for string length take string
  if (num % 2 == 0) {//and replace numm with string.length here
    return "even";
  } else {
    return "odd";
  }
}
0
for(let count =0; count<=100;count++){
 count%2==0? console.log(`${count} is even`):console.log(`${count} is odd`);
 ;
}
1
let isEven = (n) => !(n&1);
-1

New to Communities?

Join the community