Created
September 6, 2019 18:53
-
-
Save masautt/9f149ed3ec221795efd0d6ae97854568 to your computer and use it in GitHub Desktop.
How to remove all odd numbers from an array in JavaScript?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function removeOdds(arr){ | |
return arr.filter(function (num) { | |
return num % 2 === 0; | |
}); | |
} | |
console.log(removeOdds([8,6,7,5,3,0,9])); // --> [ 8, 6, 0 ] | |
// https://stackoverflow.com/questions/18305431/how-to-remove-all-odd-numbers-in-an-array-using-javascript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment