Blogger Information
Blog 34
fans 0
comment 0
visits 39176
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js基础循环 ——第五期线上——2019-3-26
黄健的博客
Original
708 people have browsed it

for循环打印99乘法表

<script language=javascript>
for(i=1;i<=9;i++){
for(j=1;j<=9;j++){
document.write (i+"*"+j+"="+i*j+"&nbsp;");
if(i==j)
{
document.write ("<br/>"); break;
}
}
}
</script>

while循环打印三角形,没想出来。

用for循环

<script type="text/javascript">
//打印一个三角形(外循环控制行,内循环控制列)  
for(var i = 1; i <=52; i++) {//控制行
 
for(var j = 1; j <= 52- i; j++) {//控制列
document.write("*");
}
 
document.write("<br/>")
}
</script>


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post