打印以前的答案

时间:2015-07-13 18:21:11

标签: javascript jquery

我正在创建一个用户必须尝试猜测代码组合的游戏。我希望用户能够看到他之前的尝试。但是目前我只能得到他们所在的div框来显示他们最近的代码。

这是函数所在的代码。

Game.countAnimals = function(playerGo){

        var count = {bulls:0, cows:0};
        Game.counter = 1;
        for (var i = 0; i < playerGo.length; i++) {
            var digPresent = playerGo.indexOf(Game.score[i]);
            if (playerGo[i] == Game.score[i]) {count.bulls++;}
            else if (digPresent>=0) {count.cows++;}
            Game.counter++
            if (count.bulls == playerGo.length && Game.counter < 7){
                console.log("you have won")}
                else if (count.bulls !== playerGo.length && Game.counter < 7) {
                    console.log("Sorry Homes")}
                    else if (count.bulls !== playerGo.length && Game.counter > 7 ){console.log ("you lose");}




                }
                $(".scoreboard1").html(count.cows);
                $(".scoreboard2").html(count.bulls);

0 个答案:

没有答案