Created
January 4, 2017 18:27
-
-
Save rproenza86/62e95eb82166018da0afc8f46ea253a0 to your computer and use it in GitHub Desktop.
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
/** | |
Code Challenge Needed: | |
Using Javascript, given an array of n integers (example: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 112, 113] ), remove all odd numbers, leaving only the even numbers. | |
Rules: | |
NO LOOPING. This means native methods, or libraries that loop for you are not allowed either. | |
Supply the answer on github via Gist | |
**/ | |
var numbersArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 112, 113]; | |
console.log('The original numbers array was : ', numbersArray); | |
window.prompt('The original numbers array was : ', numbersArray); | |
var evensArray = numbersArray.filter( (number) => { | |
return (number % 2) != 1 ; | |
}); | |
console.log('The evens numbers are : ', evensArray); | |
window.prompt('The final evens numbers array is : ', evensArray); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment