一切正常运行,但我想添加一些东西。在函数的最后,我想通过比较你想要回答的数量,但是用一个百分比来改变画布的高度。很抱歉,如果这很难理解。使用if语句来获得输入的百分比?
的JavaScript:
<script type="text/javascript">
function myFunction() {
score = 0;
questionAmount = prompt('How many question would you like to solve?');
for(i = 0; i < questionAmount; i++) {
var x = Math.floor(Math.random() * 13);
var y = Math.floor(Math.random() * 13);
question = prompt('What is ' + x + ' * ' + y + ' = ?');
if(question == null || isNaN(question)) {
break;
}
if(question == x * y) {
score++;
}
}
alert('You got ' + score + ' out of ' + questionAmount + ' correct.');
}
</script>
HTML:
<canvas id="content"></canvas>
<br />
<button onclick="myFunction()">CLICK</button>
所以,你想一些酒吧,是更大的,当用户有更多的问题正确? [类似这样的东西?](http://www.asp.net/ajaxlibrary/GetFile.aspx?Page=jquery_ui_mvc_progressbar&File=basic.PNG) – Kevin
你遇到了什么问题? – Bergi
是的,凯文,这个例子与我想要的非常相似。 – user2793503