javascript filter odd numbers code example
Example 1: javavscript use .filter to return odd numbers in an array
let arr = [1,2,3,4,5,6,7,8,9,10,11,12]
let odds = arr.filter(n => n%2)
console.log(odds)
Example 2: filter even numbers javascript
var arr = [-200, -163, -26, -4, 0, 7, 76];
var evens = arr.filter(x => x % 2 === 0);
// Array(5) [ -200, -26, -4, 0, 76 ]