number is even or odd fucntion in javascript
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";
}
}<!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:
- get params from route vuejs
- react bootstrap make col disapear in small screens
- sweet alert js
- radium is not working
- jquery ajax json
- how to update react app
- passing a variable to the width style div angular
- event loop in javascript
- universal apollo kit
- how get parent element javascript
- javascript function from string
- jest async test fetch api
- get multiple checkbox value in javascript
- check the doc name in javascript
- angular on back skip routes
- javascript loop over classlist
- .shift js
- how to access any argument in javascript
- select input by name javascript
- Truthy and Falsy js
- how to draw a flower in javascript
- regular expression for email and mobile
- javascript get sub array
- make object move towards player p5js