odd or even js
function isEven(n) {
return n % 2 == 0;
}
function isOdd(n) {
return Math.abs(n % 2) == 1;
}function evenOrOdd(num) { //for string length take string
if (num % 2 == 0) {//and replace numm with string.length here
return "even";
} else {
return "odd";
}
}for(let count =0; count<=100;count++){
count%2==0? console.log(`${count} is even`):console.log(`${count} is odd`);
;
}<!DOCTYPE html>
<html>
<body>
<script>
var num = 5;
document.write("Number = "+num+"<br>");
if(num % 2 == 0) {
document.write('Number is even!');
} else {
document.write('Number is odd!');
}
</script>
</body>
</html>
Also in JavaScript:
- how to add data to array in javascript dynamically
- usestate access previous state
- javascript check if all capital letter
- express how to access ajax post data
- javascript reload page
- class extends
- javascript data structures
- args slice discord.js
- get gcf javascriot
- Date gethours js
- free map js
- print value in jquery
- asdasd junsd js
- settimeout in vuejs
- hide element js
- validate gender in javascript
- jquery remove elemtns
- Module not found: Can't resolve '@date-io/date-fns' in 'C:\Users\61455\Documents\React apps\mya2o\src\pages'
- how to call function from another js file in react native
- how to remove duplicates in array in javascript
- how to make @click in router-link vuejs
- get input field inside div jquery
- express unique validator for the owner
- javascript append to html table tr