Skip to content

Instantly share code, notes, and snippets.

@mason276752
Created June 30, 2020 01:52
Show Gist options
  • Save mason276752/d111f7d03b119bb694ff72b381443364 to your computer and use it in GitHub Desktop.
Save mason276752/d111f7d03b119bb694ff72b381443364 to your computer and use it in GitHub Desktop.
// let mobiles=["xxxx":{"to":"oooo","count":0,"finded":false},...]
let ms=Object.keys(mobiles)
ms.forEach(function active(mobile){
if(!mobiles[mobile].finded && mobiles[mobile].count<3 && mobiles[mobile].to!==""){
mobiles[mobile].count=mobiles[mobile].count+1
if(!mobiles[mobiles[mobile].to]){
mobiles[mobile].finded=true
return console.log('can not found ',mobiles[mobile].to)
}else{
active(mobiles[mobile].to)
}
}
mobiles[mobile].finded=true
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment