Created
September 6, 2019 18:55
-
-
Save masautt/7c7766dc75bfd420df4d53c58133b866 to your computer and use it in GitHub Desktop.
How to remove all even 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 removeEvens(arr){ | |
return arr.filter(function (num) { | |
return num % 2 !== 0; | |
}); | |
} | |
console.log(removeEvens([8,6,7,5,3,0,9])); // --> [ 7, 5, 3, 9 ] | |
// 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