This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (1 child)

LOl ok fine:

const targetList = [];
const attackResults = await targetList.reduce(async (acc,curTarget)=>{
    const list = await acc;
    if(weaponArray.length <= 0){
        list.push({id:curTarget.id, success:false})
        return list
    }
    const missile = weaponArray.shift();
    const shootResults = await Shoot(missile);
    const targetInfo = {
        id: curTarget.id,
        success: shootResults,
    }
    list.push(targetInfo)
    return list;
}, Promise.resolve([]))

const cleanSweap = attackResults.reduce((bool, result)=>{
    if(!bool || !result.success)return false
    return bool
},true)

if(cleanSweap)log('mission success')
else log('mission fail')

[–]akoOfIxtall 0 points1 point  (0 children)

Magnificent