意外的结果-初学者JavaScript

时间:2019-04-05 13:53:32

标签: javascript

所以我计算了变量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;
 }

0 个答案:

没有答案