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;
}
Also in JavaScript:
- Title
- how to change a variables value in javascript
- Category
- JavaScript
- Title
- how to add variable to local storage in javascript
- Category
- JavaScript
- Title
- express route parameters
- Category
- JavaScript
- Title
- how to add objects in array
- Category
- JavaScript
- Title
- create react native app npx
- Category
- JavaScript
- Title
- compare the triplets hackerrank solution in javascript
- Category
- JavaScript
- Title
- how to remove the id in mongoose schema
- Category
- JavaScript
- Title
- extend react.component
- Category
- JavaScript
- Title
- clear scene\
- Category
- JavaScript
- Title
- how reliable is js hasownproperty
- Category
- JavaScript
- Title
- Vue.js force to reload re-render
- Category
- JavaScript
- Title
- declare function javascript
- Category
- JavaScript
- Title
- defineCall is not a function at Sequelize.import sequelize.js
- Category
- JavaScript
- Title
- 'Link' is not defined react/jsx-no-undef
- Category
- JavaScript
- Title
- get value of hidden field jquery
- Category
- JavaScript
- Title
- how to find out what a string ends with in javascript
- Category
- JavaScript
- Title
- dataset js
- Category
- JavaScript
- Title
- how to make javascript function consise
- Category
- JavaScript
- Title
- how to show hide div in html javascript
- Category
- JavaScript
- Title
- checked unchecked through js
- Category
- JavaScript
- Title
- how to make a property important in javascript
- Category
- JavaScript
- Title
- array contains case insensitive javascript
- Category
- JavaScript
- Title
- graphql react filtering
- Category
- JavaScript
- Title
- disable button click jquery
- Category
- JavaScript
- Title
- how to store value in session using javascript in php
- Category
- JavaScript
- Title
- check if string is datestring javascript
- Category
- JavaScript
- Title
- discord.js
- Category
- JavaScript
- Title
- filereader javascript example
- Category
- JavaScript
- Title
- Add object to array javascript
- Category
- JavaScript
- Title
- default pool size in sequelize
- Category
- JavaScript
- Title
- how to remove a property from an object in javascript
- Category
- JavaScript
- Title
- bootstrap 4 open tab when opening modal
- Category
- JavaScript
- Title
- add firebase in react
- Category
- JavaScript
- Title
- how to craete a shopping cart in node js
- Category
- JavaScript
- Title
- array unique values javascript
- Category
- JavaScript
- Title
- convert array object to string javascript
- Category
- JavaScript
- Title
- import axios react
- Category
- JavaScript
- Title
- accèder data-id javascript
- Category
- JavaScript
- Title
- declare multiple variables javascript
- Category
- JavaScript
- Title
- how to parse query string in node.js lambda
- Category
- JavaScript
- Title
- How to pass a map from controller to javascript function in VF page
- Category
- JavaScript
- Title
- check if localstorage key exists js
- Category
- JavaScript
- Title
- function clear() p5js how das this work
- Category
- JavaScript
- Title
- get current url js
- Category
- JavaScript
- Title
- javascript add day to date
- Category
- JavaScript
- Title
- how to validate date in react
- Category
- JavaScript
- Title
- get a div text content and store in a variable js
- Category
- JavaScript
- Title
- how to make a show password button
- Category
- JavaScript
- Title
- add custom marker in react-mapbox-gl
- Category
- JavaScript
- Title
- enzyme test method
- Category
- JavaScript
- Title
- how to turn decimales into percents with javascript
- Category
- JavaScript
- Title
- change node version
- Category
- JavaScript
- Title
- display none js
- Category
- JavaScript
- Title
- how to open new tab in vscode using keyboard
- Category
- JavaScript
- Title
- discord.js how to go back a file
- Category
- JavaScript
- Title
- 2gis nuxt
- Category
- JavaScript
- Title
- how to check version of node js in cmd
- Category
- JavaScript
- Title
- append rotated triangle in anchor tag
- Category
- JavaScript
- Title
- flutter cache json
- Category
- JavaScript
- Title
- change input placeholder text jquery
- Category
- JavaScript
- Title
- 404 json laravel
- Category
- JavaScript
- Title
- get the value of a checkbox jquery
- Category
- JavaScript
- Title
- how to check if variable is array in javascript
- Category
- JavaScript
- Title
- fetch response json or text
- Category
- JavaScript
- Title
- how to make an async function
- Category
- JavaScript
- Title
- how to generate random character from an array js
- Category
- JavaScript
- Title
- how to appendChild in the begin of the div javascript
- Category
- JavaScript
- Title
- Javascript - Track mouse position
- Category
- JavaScript
- Title
- how to output to console java
- Category
- JavaScript
- Title
- how to access all images in a document javascript
- Category
- JavaScript
- Title
- add dynamic value to id attribute in angular 8
- Category
- JavaScript
- Title
- angular run with proxy
- Category
- JavaScript
- Title
- apache log format json
- Category
- JavaScript
- Title
- background-image url not working
- Category
- JavaScript
- Title
- how to make a page relode on a keypress in js
- Category
- JavaScript
- Title
- convert 24 hour to 12 hour moment js
- Category
- JavaScript
- Title
- content disposition attachment javascript fetch download "excel"
- Category
- JavaScript
- Title
- async await catch error
- Category
- JavaScript
- Title
- create bottom navigation bar react native
- Category
- JavaScript
- Title
- bracket notation javascript
- Category
- JavaScript
- Title
- How to get row index and cellindex together in javascript
- Category
- JavaScript
- Title
- .map function
- Category
- JavaScript
- Title
- check the doc name in javascript
- Category
- JavaScript
- Title
- javascrip reverse text
- Category
- JavaScript
- Title
- fetch api javascript
- Category
- JavaScript
- Title
- how to get user ip address in javascript
- Category
- JavaScript
- Title
- javascript check if number
- Category
- JavaScript
- Title
- async await arrow function
- Category
- JavaScript
- Title
- get last char javascript
- Category
- JavaScript
- Title
- check if checkbox is checked javascript
- Category
- JavaScript
- Title
- finding an element ina na array in js
- Category
- JavaScript
- Title
- how to use for of in javascript
- Category
- JavaScript
- Title
- how to return an object in javascript
- Category
- JavaScript
- Title
- Finding HTML Element by Id
- Category
- JavaScript
- Title
- add variable numerically in javascript
- Category
- JavaScript
- Title
- javascript adding an array to an array
- Category
- JavaScript
- Title
- javascript async fetch file html
- Category
- JavaScript
- Title
- angular npx
- Category
- JavaScript
- Title
- get current url react router
- Category
- JavaScript
- Title
- how to create component in reactjs
- Category
- JavaScript