dimanche 30 décembre 2018

Why does my second if statement run 2 times in a row after my first if statement is true?

Hello guys I have a problem with my checkRight() function. I tried to build a quiz webpage with js. Here is my complete code: https://www.codeply.com/go/qoCnPUDDxG My questions consists of a class with: question (string), answers(array of strings) and answer (string) attributes. If I click on the right answers my counters go very confusing up.

function checkRight (){
  $(".answer").click(function() {
       check = $(this).html();
       if(check===qAry[i].rightAnswer){
         rightCounter++;
         $(".richtigZaehler").text(rightCounter);
         i++;
         askQ();
       }
         else if(check!=qAry[i].rightAnswer){
         console.log("Update");
         wrongCounter++;
         $(".falschZaehler").text(wrongCounter);
      }
  });
}

Aucun commentaire:

Enregistrer un commentaire