Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

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

log odd numbers js

for(var n = 0; n <= 10; n+=2) console.log(n)
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 :: assign array to another array javascript 
Javascript :: react native navigation change header title 
Javascript :: use bootstrap 5 with vue 
Javascript :: what is status 400 in react 
Javascript :: switch alert 
Javascript :: use setstate in function component 
Javascript :: variable for every user discord.js 
Javascript :: how to get the inner width of a parent div for canvas 
Javascript :: node js response header 
Javascript :: npm run build npm ERR! Missing script: "build" for firebase 
Javascript :: js code sample 
Javascript :: leap year function javascript 
Javascript :: javascript slice vs splice 
Javascript :: hash object javascript 
Javascript :: regex youtube id 
Javascript :: spotify web player 
Javascript :: remove repetition multidimensional array javascript 
Javascript :: convert json to table in sql server 
Javascript :: getmilliseconds javascript 
Javascript :: how to run react builed version 
Javascript :: how to do joins in sequelize and select things from the third table 
Javascript :: vuejs vscode unbound breakpoint 
Javascript :: how to validate phone number regex javascript 
Javascript :: cookie options 
Javascript :: js get all dublicates indexes in array 
Javascript :: mongodb unwind 
Javascript :: cookie in javascript 
Javascript :: css on javascript 
Javascript :: callback hell javascript 
Javascript :: Quick Git Setup 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =