array return odd numbers javascript code example
Example 1: check if even or odd javascript
function evenOrOdd(num) { //for string length take string
if (num % 2 == 0) {//and replace numm with string.length here
return "even";
} else {
return "odd";
}
}
Example 2: find even numbers in an array javascript
arr.filter(num => num % 2)