需要为jquery中的琐事游戏生成分数

时间:2018-09-05 23:54:18

标签: javascript jquery

question with answer    
 {
        question: "Rogue was adopted by whom?",
        answers: [
          "Xavier",
          "Wolverine",
          "Jean Gray",
          "Mystique"
        ],
        correctAnswer: 1
      }

    //// print questions and answers for rogue
    $(".rogue").append(myQuestions[5].question);

    for (i = 0; i < myQuestions[5].answers.length; i++) {
      $('<li><input type="radio" name="rbtnCount" value =' + i + '>' + myQuestions[4].answers[i] + "</li>").appendTo(".rogue")
    }
    $(".rogue").on("change", function () {
      var selected = $('input[name=rbtnCount]:checked').val();
      console.log(selected)
      console.log(myQuestions[5].correctAnswer)
      if (selected == myQuestions[5].correctAnswer) {
        alert("its right!!!")
      } else {
        alert("better luck on nextone!!")
      }
    })

    /// print score based on correct and incorrect
    $(".corr").append(correctAnswer);
      if(correctAnswer)  <--- not certain on my next step here to create the scoring. 

////我被困在这里,不了解我的下一步。需要根据所选的正确答案和不正确的分数创建分数。

0 个答案:

没有答案