Skip to content

Instantly share code, notes, and snippets.

@albertywu
Last active January 23, 2017 19:13
Show Gist options
  • Select an option

  • Save albertywu/f71937bc173d3fa49a913efdf8866f2f to your computer and use it in GitHub Desktop.

Select an option

Save albertywu/f71937bc173d3fa49a913efdf8866f2f to your computer and use it in GitHub Desktop.
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