how to check if a number is even or odd in javascript

JavaScript
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));// C++ program to check for even or odd 
// using Bitwise XOR operator 
  
#include <iostream> 
using namespace std; 
  
// Returns true if n is even, else odd 
bool isEven(int n) 
{ 
  
    // n^1 is n+1, then even, else odd 
    if (n ^ 1 == n + 1) 
        return true; 
    else
        return false; 
} 
  
// Driver code 
int main() 
{ 
    int n = 100; 
    isEven(n)  
? cout << "Even" 
: cout << "Odd"; 
  
    return 0; 
} 

Source

Also in JavaScript: