Last active
January 23, 2017 19:13
-
-
Save albertywu/f71937bc173d3fa49a913efdf8866f2f 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
| const returnedDrones = {} | |
| function dispatchDrones(drones) { | |
| drones.forEach(d => { | |
| droneId = d.dispatch() // droneId contains a random but unique id | |
| returnedDrones[droneId] = false | |
| } | |
| } | |
| // run this function at end of day | |
| function findMissing() { | |
| return ( | |
| Object | |
| .keys(returnedDrones) | |
| .map(id => [id, returnedDrones[id]]) | |
| .find(([id, isReturned]) => isReturned == false) | |
| )[0] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment