//while循环
var a=1,b=0;
while(a<=100)
{
b=b+a;
a++;
}
document.write("1+2+3+…+100="+b+"<br/>");
document.write("------------------------------<br/>");
//do...while循环
var c=1,d=0;
do{
d=d+c;
c++;
}
while(c<=100);
document.write("1+2+3+…+100="+d+"<br/>");
document.write("------------------------------<br/>");
//for循环
var e=0;
for(var f=1;f<=100;f++)
{
e+=f;
}
document.write("1+2+3+…+100="+e+"<br/>");
<!DOCTYPE html>
<html>
<head>
<meta charsrt="utf-8" />
<title></title>
</head>
<body>
<script>
</script>
</body>
</html>