Created
August 2, 2014 15:38
-
-
Save bradoyler/a8b675d07a0c468ac380 to your computer and use it in GitHub Desktop.
filter array & display time it occured
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
function findIds(arr, filterFn) { | |
var results = arr.filter(filterFn); | |
results.timestamp = new Date(); | |
return result; | |
} | |
var ids = [0, 1, 2, 8, 4, 4, 5, 6, 7, 8, 9]; | |
var filtered = findIds(ids, function(x) { | |
return (x == 8); | |
}); | |
console.log(filtered); // Outputs: [8, 8, timestamp: Sat Aug 02 2014 11:36:13 GMT-0400 (EDT)] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment