Blogger Information
Blog 3
fans 0
comment 0
visits 1622
Related recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0326作业
Z-X-P的博客
Original
533 people have browsed it

总结:for in 用法跟foreach用法类似都是取到数据的下标

        形参跟实参,形参是在函数定义时括号内的变量,实参是实际参进去函数的值。

99乘法表,正三角形的话第二个循环中for(j=1;j<=i;j++)

实例

<script type="text/javascript">
	for(var i=1;i<9;i++)
		{
			for(var j=i;j<=9;j++)
			{
				document.write(i+'x'+j+'='+(i*j)+' '+' ');

			}
			document.write('<br>');
		}	
</script>

运行实例 »

点击 "运行实例" 按钮查看在线实例

用while打印一个星号三角形


实例

<script type="text/javascript">
var i = 1;
		while(i<20)
		{
			for(var z=i;z<=20;z++)
			{
				document.write('&nbsp');
			}
			for(var j=1;j<=2*i-1;j++)
			{
				document.write('*');
			}
			document.write('<br>');
			i++;
		}
</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