Javascript jQuery简单测验不起作用

Javascript jQuery简单测验不起作用,javascript,jquery,html,Javascript,Jquery,Html,我只是在学习Javascript和jQuery。我做了一个简单的测试,基本上是失败的,但我已经把问题缩小到我的代码。我确信所有ID都已链接,并且jQuery已正确连接到CDN。我知道我可以一个接一个地问问题,但我认为这是草率的编码 从 HTML: 结束所有测验的测验 这个页面是一个实验,看看我是否可以使用JavaScript和jQuery制作一个问答游戏。 请不要用标点符号回答 单击此处显示答案 问:谁是第一位非洲裔美国职业棒球大联盟球员?A:杰基·罗宾逊 问:美国第二任总统是谁?A:约翰·亚当

我只是在学习Javascript和jQuery。我做了一个简单的测试,基本上是失败的,但我已经把问题缩小到我的代码。我确信所有ID都已链接,并且jQuery已正确连接到CDN。我知道我可以一个接一个地问问题,但我认为这是草率的编码

HTML:
结束所有测验的测验
这个页面是一个实验,看看我是否可以使用JavaScript和jQuery制作一个问答游戏。
请不要用标点符号回答

单击此处显示答案

问:谁是第一位非洲裔美国职业棒球大联盟球员?A:杰基·罗宾逊

问:美国第二任总统是谁?A:约翰·亚当斯

问:将军的军队驻扎在哪里?A:在他的袖子里

问:为什么小鸡要过马路?A:去另一边

问:为什么稻草人得到提升?A:他在这个领域很出色

单击此处隐藏答案

Javascript: $(文档).ready(函数(){ var评分; 变量问题=[ “谁是第一位非洲裔美国职业棒球大联盟球员?”, “谁是美国第二任总统?”, “将军把他的军队放在哪里?”, “小鸡为什么过马路?”, “稻草人为什么得到提升?” ]; var答案=[ “杰基·罗宾逊”, “约翰·亚当斯”, “在他的袖子里”, “去另一边”, “他在自己的领域很出色” ]; $(“#答案”).hide()//隐藏答案 $(“#开始”)。单击(函数(){
for(num=0;num我在代码中发现了两个错误,都在for循环中


首先,for循环在
num后面有一个逗号而不是分号要添加代码,请单击
{}
按钮并粘贴到您的代码中。我已在上面对其进行了修复。出于兴趣,由于错误与缺少字符有关,您使用的文本编辑器是什么?带有代码提示的编辑器可能有助于避免将来出现此类错误
HTML: <!DOCTYPE html>
<html>
    <head>
        <meta charset="Utf-8">
        <title>The quiz to end all quizes</title>
        <link rel="stylesheet" href="style.css">
        <script src="libs/jquery-1.11.0.min.js"></script>
        <script src="script.js"></script>
        <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
        <link rel="icon" href="favicon.ico" type="image/x-icon">
    </head>
    <body>
        <div id="main">
            <div id="header">
                <img src="images/logo.png">
                <h2>This page is an experiment to see if I can use JavaScript and jQuery to make a quiz game.</h2>
                <p>Please answer with no punctuation.</p>
                <p id="show">Click here to show answers.</p>
                <img id="start" src="images/clickme.png">
            </div>
            <div id="answers">
                <!-- CHEATER!!! -->
                <p><span id="ans1"></span>Q: Who was the first African-American major league baseball player? A: Jackie Robinson</p>
                <p><span id="ans2"></span>Q: Who was the second U.S. President? A: John Adams</p>
                <p><span id="ans3"></span>Q: Where did the general keep his armies? A: In his sleevies</p>
                <p><span id="ans4"></span>Q: Why did the chicken cross the road? A: To get to the other side</p>
                <p><span id="ans5"></span>Q: Why did the scarecrow get a promotion? A: He was outstanding in his field</p>
                <h2 id="numright"></h2>
                <p id="hide">Click here to hide answers.</p>
            </div>
        </div>
    </body>
</html>

Javascript:
$(document).ready(function() {
    var score;
    var questions = [
                    "Who was the first African-American major league baseball player?", 
                    "Who was the second U.S. President?",
                    "Where did the general keep his armies?",
                    "Why did the chicken cross the road?",
                    "Why did the scarecrow get a promotion?"
                    ];
    var answers = [
                    "jackie robinson",
                    "john adams",
                    "in his sleevies",
                    "to get to the other side",
                    "He was outstanding in his field"
                    ];
    $('#answers').hide() // hide answers
    $('#start').click(function() {
        for (num=0; num<5, num++){
            var ans = prompt(questions[num], "Enter Answer Here")
            if (ans == answers[num])
                score++
            } // end if
        } // end for
        $('#answers').show() // show answers
        $('#show').hide() // hide show
        $('#numright').write('You got ' + score + '/5')
    }); // end click
    $("#show").click(function() {
        $('#answers').show() // show answers
        $('#show').hide() // hide show button
    }); // end click
    $("#hide").click(function() {
        $('#answers').hide() // hide answers
        $('#show').show() // show show button
    }); // end click    
}); // end ready
for (num=0; num<5; num++) {
    var ans = prompt(questions[num], "Enter Answer Here")
    if (ans == answers[num]) {
        score++
    } // end if
} // end for
var score = 0;