JavaScript基础教程

文章39 |   阅读 11539 |   点赞0

来源:https://blog.csdn.net/u011541946/category_6887610.html

JavaScript学习笔记19-for循环

x33g5p2x  于2022-03-06 转载在 其他  
字(0.6k)|赞(0)|评价(0)|浏览(270)

前面文章介绍的是if语句,if语句是一种条件控制语句。本文来学习下循环语句,先看看for循环。

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
</head>
<body>
<script type ="text/javascript">
	for (i=0;i<10;i++){
		document.write("I am learing JavaScript!" +"<br />");
	}
	// 设置步长
	for (j=0;j<10;j+=3){
		document.write("for 循环经常要计算好步长,这里步长是3" +"<br />");
	}
</script>
</body>
</html>

练习:自己试试能不能写出从1相加到100的for循环语句?

相关文章