所以我计算了变量winningDecision
并打印到控制台-结果正确。
然后,我尝试将winningDecision
推入另一个Array (winDecide)
。当我控制台winDecide时,结果不正确。例如,如果winningDecision
是"draw"
,则"player"
被推送。
任何解释都将非常有帮助。在此先感谢您-我是JavaScript新手。
for (var k =0;k<dealerScoreHolder.length;k++)
{
var winningDecision = JSON.parse(JSON.stringify(winnerCalc(playerPossibilities[i][1],dealerScoreHolder[k][2])));
console.log(winningDecision);
winDecide.push([winningDecision,dealerScoreHolder[k][0]]);
console.log(winDecide);
if(winDecide[k][0]="player")
{chancesWin[0]+=winDecide[k][1]
}
else if (winDecide[k][0]="draw")
{chancesWin[1]+=winDecide[k][1]
}
else if (winDecide[k][0]="dealer")
{chancesWin[2]+=winDecide[k][1]
}
console.log(chancesWin);
debugger;
}