-
-
Save morisasy/e1f964ccf282e4d436f47855c4e5364b to your computer and use it in GitHub Desktop.
Given an array and a keeper element, create a function "keep" returns an array containing the items that match the given keeper element.
This file contains 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
Notes: | |
* If no elements match, "keep" should return an empty array. | |
function keep(array, keeper) { | |
if(Array.isArray(array) === false){ | |
return null; | |
} | |
return array.filter(function(value) { | |
return value == keeper; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment