Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.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
使用doc.write显示Javascript的数组中的算术序列_Javascript_Arrays - Fatal编程技术网

使用doc.write显示Javascript的数组中的算术序列

使用doc.write显示Javascript的数组中的算术序列,javascript,arrays,Javascript,Arrays,因此,目标是生成一个算术序列,从7开始,差为9。所以7、16、25、34等等 您必须这样做20次,并创建一个单列表,使用document.write()自动生成每个数字的行来打印它 我相信我了解如何制作一个20的数组,并在数组中输入数学。这就是我目前所知道的 <!DOCTYPE html> <html lang="en"> <head> <title>Javascript Arithmetic Sequence</titl

因此,目标是生成一个算术序列,从7开始,差为9。所以7、16、25、34等等

您必须这样做20次,并创建一个单列表,使用document.write()自动生成每个数字的行来打印它

我相信我了解如何制作一个20的数组,并在数组中输入数学。这就是我目前所知道的

<!DOCTYPE html>
<html lang="en">
<head>
<title>Javascript Arithmetic Sequence</title>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />

</head>
<body>

<script type ="text/javascript">
var result =[20];

for (var a = 7; a + 9; a++) {
    document.write("<table>"+
            "<tr>"+
            "<th> Arithmetic Sequence of 7</th>"+
            "<td>"+ result+"</td>"+
            "</tr>"+
            "</table>");
}
</script>


<p>Question 1: You would need to change the array length.</p>
<br>
<p>Question 2: You use document.write() to display HTML document content and not pop up as a button/alert using alert().</p>



</body>
</html>

Javascript算术序列
var结果=[20];
对于(变量a=7;a+9;a++){
文件。写(“”)+
""+
“7的算术序列”+
“”+结果+“”+
""+
"");
}
问题1:您需要更改数组长度


问题2:您使用document.write()来显示HTML文档内容,而不是使用alert()以按钮/警报的形式弹出

问题是,我的HTML网站上没有显示任何内容,JS验证器一直说document.write()可以用作“eval”(我不明白这是什么意思)。我上下浏览了我的章节,在谷歌上搜索了一些建议(这远远超出了章节的内容)。看看是否有人能发现我可能错在哪里,或者就我需要调整的地方给出建议


谢谢。

玩弄它,终于得到了答案。谢谢所有帮助过我的人

<script type ="text/javascript">
var table = "<table border =1><tr><th>Arithmetic Sequence of d=9</th></tr>";
var result = 7 ;

for (var count = 0; count <20; count++) {
    result = result + 9;
    table+="<tr><td>"+ result +"</td>",
    "</tr>";
            
}
table+="</table>";
document.write(table);
</script>

var table=“d=9的算术顺序”;
var结果=7;

对于(var count=0;count将逗号替换为+表示串联,并且缺少起始表标记。因此,您的意思是,``document.write(“,”,“7的算术序列,”“+result+”,”“,”“)“``所有comas replace为+仅tr表行应位于for循环内,表标记应位于纯html的外部。因此,我将所有逗号替换为+,但我的网页只是保持加载状态,验证程序没有说任何内容。因此,我看不到结果。我将放置整个html以查看外部是否有错误。