-
-
Save KinyuaMwaniki/2e8424d6ecc8c8253897d99c12d4f41b to your computer and use it in GitHub Desktop.
Filter Arrays with filter
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
| var oldArray = [1,2,3,4,5,6,7,8,9,10]; | |
| // We declare our newArray which holds the .filter method, filter proceeds to grab each element in our array, | |
| // and pass them as arguments to the function which returns our result. | |
| var newArray = oldArray.filter( function(a) { | |
| return a < 6; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment