Blogger Information
Blog 3
fans 0
comment 0
visits 1960
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
前端基础-JavaScript基础-第五期线上班
Freeflight的博客
Original
612 people have browsed it

【案例1】js打印九九乘法表

实例

<script>

for (var a=1;a<=9;a++){
	for (var b=a;b<=9;b++){
		
		var kong="   "
		if(a*b<10){
			kong+="  ";
			
			};
		
		document.write(a+"x"+b+"="+a*b+kong)
		
		}
		document.write("<br/>");
	};


</script>

运行实例 »

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



【案例2】计算:用*号在页面中输出一个三角形(while)


实例

<script>


var x,j,y;
		x=1;
		while(x<=5){
			j=1;
			while(j<=(5-x)){
				document.write("<center>"+" ");
				j++;
			}
			y=1;
			while(y<=(2*x-1)){
				document.write("*");
				y++;
			}
			x++;
			document.write("<center>"+"<br>");
 
	
	}


</script>

运行实例 »

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





for循环:

实例

<script>



for(var i=1;i<=4;i++){

    for(var k=1;k<=4-i;k++){

        document.write(' ')

    }

    for(j=1;j<=2*i-1;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