Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从迭代中返回变量_Javascript_Html - Fatal编程技术网

Javascript 如何从迭代中返回变量

Javascript 如何从迭代中返回变量,javascript,html,Javascript,Html,大家好,我正在创建这个javascript问答应用程序,我有一些我无法理解的bug 它显示正确,但错误所在的位置是在输出处,该输出应返回您已回答的问题总数中未回答的问题。如果该值为真,则此处仅显示0 下面是我的脚本。 谢谢 var pos=0, 测试,测试状态,问题,选择,选择,chA,chB,chC,正确=0; 变量问题=[ [什么是10+4?、12、14、16、B], [什么是10+5?、15、14、16、A], [什么是20+4?、12、24、16、B], [什么是30+4?、32、24

大家好,我正在创建这个javascript问答应用程序,我有一些我无法理解的bug

它显示正确,但错误所在的位置是在输出处,该输出应返回您已回答的问题总数中未回答的问题。如果该值为真,则此处仅显示0

下面是我的脚本。 谢谢

var pos=0, 测试,测试状态,问题,选择,选择,chA,chB,chC,正确=0; 变量问题=[ [什么是10+4?、12、14、16、B], [什么是10+5?、15、14、16、A], [什么是20+4?、12、24、16、B], [什么是30+4?、32、24、34、C], [什么是10+6?、12、14、16、C] ]; 函数{ return document.getElementByIdx; } 函数渲染问题{ 测试=_测试; 如果pos>=questions.length{ test.innerHTML=你得到了+correct+of+questions.length+questions correct; _test_status.innerHTML=测试已完成; pos=0; 正确=0; 返回false; } _test_status.innerHTML=Question+pos+1+of+questions.length; 问题=问题[pos][0]; chA=问题[pos][1]; chB=问题[pos][2]; chC=问题[pos][3]; test.innerHTML=+question+; test.innerHTML+=+chA+; test.innerHTML+=+chB+; test.innerHTML+=+chC+; test.innerHTML+=提交答案; } 函数校验应答{ choices=document.getElementsByNamechoices; 对于变量i=0;i
choices = document.getElementsByName("choices");
console.log(choices)
将显示它不返回任何元素

为什么!?因为你把选项拼错了

name='chioces'

没有你的回答。。。在代码发布中,整个html将使调试方式更容易。