Javascript 在所有情况下,都必须将回合转换为状态为真的玩家

Javascript 在所有情况下,都必须将回合转换为状态为真的玩家,javascript,Javascript,在所有情况下,都必须将回合转换为状态为真的玩家。如何正确地做 const arr=[false,false,false,false,true,false]//false-退出,true-播放 常数存储={ 玩家:1,//随过渡而变化 多人:6人 } const newArr=arr.slice(DiceStore.players-1,DiceStore.multi) console.log('newArr',newArr) log(`newArr.indexOf(true)`,newArr.in

在所有情况下,都必须将回合转换为状态为真的玩家。如何正确地做

const arr=[false,false,false,false,true,false]//false-退出,true-播放
常数存储={
玩家:1,//随过渡而变化
多人:6人
}
const newArr=arr.slice(DiceStore.players-1,DiceStore.multi)
console.log('newArr',newArr)
log(`newArr.indexOf(true)`,newArr.indexOf(true))
const lengthArray=newArr.length
console.log(`lengthArray`,lengthArray)
//DiceStore.players=DiceStore.multi+lengthArray-arr.indexOf(true)-2
if(DiceStore.multi==DiceStore.players){
DiceStore.players=arr.indexOf(真)+1
}else if(newArr.indexOf(true)=-1){
console.log(`newArr.indexOf(true)=-1`)
DiceStore.players=arr.indexOf(真)+1
}else{`在这里输入代码`
console.log('else')
DiceStore.players=DiceStore.multi-lengthArray+arr.indexOf(true)+4
}
console.log(`DiceStore.players`,DiceStore.players)
有必要将回合转换为状态为true的玩家