評分:0, 年:0, 月:0, 週:0, 日:0, [+1 / -1] 最後更新:2019-09-24 23:05:20
請問這段程式碼 錯在哪裡啊 他一直說Unexpected token {
但是我怎麼檢查都沒錯啊 求救 求救~~~
let players = [
{name: '熊弟', win: 0, lose: 0,tie:0},
{name: '虎哥', win: 0, lose: 0,tie:0},
]
for(count=1;count<=10;count++){
play(count)
}
function play (count){
let bear = Math.floor(Math.random() * 6) + 1
let tiger = Math.floor(Math.random() * 6) + 1
if(bear > tiger){
console.log(`第${count}局>>>>${players[0].name}${bear}點,${players[1].name}${tiger}點\n${players[0].name}贏!\n`)
players[0].win++
players[1].lose++
}else if (bear< tiger){
console.log(`第${count}局>>>>${players[0].name}${bear}點,${players[1].name}${tiger}點\n${players[1].name}贏!\n`)
players[0].lose++
players[1].win++
}else{
console.log(`第${count}局>>>>${players[0].name}${bear}點,${players[1].name}${tiger}點\n平手!\n`)
players[0].tie++
players[1].tie++
}
}
console.log ("result")
console.log(`${players[0].name}贏${players[0].win}局,輸${players[0].lose}局\n`)
console.log(`${players[1].name}贏${players[1].win}局,輸${players[1].lose}局\n`)
console.log(`平手${players[1].tie}局\n`)
if (players[0].win > players[1].win ) {
console.log(`最終冠軍:${players[0].name}`)
} else if (players[0].win < players[1].win ) {
console.log(`最終冠軍:${players[1].name}`)
} else (players[0].win=== players[1].win){
console.log("沒輸沒贏")
}