Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Javascript Check if number is even or odd

function solution(num) {
    return num % 2 === 0 ? 'Even' : 'Odd'
}

Comment

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 ); };
Comment

javascript check if a number is even or odd

const isEven = num => num % 2 === 0;

console.log(isEven(2)); 
// Result: True
Comment

Odd number function in javascript

function isOdd(numbers) {
    if (numbers % 2 != 0) {
        return true;
    }
    return false;

}
var input = 343;
var result = isOdd(input);
console.log(result)
//Outpur: true
Comment

odd number is javascript

let arr = [1,2,3,4,5,6,7,8,9,10,11,12]

let odds = arr.filter(n => n%2)

console.log(odds)
 Run code snippetHide results
Comment

PREVIOUS NEXT
Code Example
Javascript :: js number to ascii 
Javascript :: javascript blob download 
Javascript :: react router 404 redirect 
Javascript :: angular version command 
Javascript :: javascript set and get cookie 
Javascript :: check if it is a function javascript 
Javascript :: try catch in javascript 
Javascript :: query params in next js 
Javascript :: node file change event listener 
Javascript :: japan 
Javascript :: rafraichir page javascript 
Javascript :: javascript date to hours minutes seconds 
Javascript :: jquery delete prev sibling 
Javascript :: load js file 
Javascript :: javascript get data attribute of selected option 
Javascript :: add option to select jquery 
Javascript :: cannot use import statement outside a module from the console.log 
Javascript :: get element by xpath in javascript 
Javascript :: react index.js BrowserRouter 
Javascript :: .sequelizerc File Setup 
Javascript :: document.getelementsbytagname 
Javascript :: sh 1 nodemon not found heroku 
Javascript :: combinantion of single array in node js 
Javascript :: js watch window resize 
Javascript :: vue call function every x seconds 
Javascript :: close bootstrap modal with javascript 
Javascript :: react native go to next text input 
Javascript :: how to get ip address in javascript 
Javascript :: regex only letters not spaces 
Javascript :: js onchange paramteter sring 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =