Answers for "javascript if number is odd"

7

js even or

function isEven(n) {
   return n % 2 == 0;
}

function isOdd(n) {
   return Math.abs(n % 2) == 1;
}
Posted by: Guest on September-06-2020
0

Javascript Check if number is even or odd

function solution(num) {
    return num % 2 === 0 ? 'Even' : 'Odd'
}
Posted by: Guest on July-10-2021
0

javascript program check the number even or odd

<!doctype html>
<html>
<head>
<script>
function odd_even(){
var no;
no=Number(document.getElementById("no_input").value);
if(no%2==0)
{
alert("Even Number");
}
else
{
alert("Odd Number");
}
}
</script>
</head>
<body>
Enter Any Number:<input id="no_input"><br />
<button onclick="odd_even()">Click me</button>
</body>
</html>
Posted by: Guest on June-07-2021
-1

sum of odd numbers in an array javascript

///sum of odd numbers in an array javascript without loop
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];

var evenNumbers = numbers.filter(function(item) {
   return (item % 2 == 0);
});

console.log(evenNumbers);
Posted by: Guest on July-10-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language