使用JS写1加到100

in hive-180932 •  4 months ago 

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Document</title>

</head>

<body>

</body>

<script>

var n=0;

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

n+=i;

}

document.write(n);

document.write("<br>");

var c='';

for(var b=1;b<=100;b++){

c=c+b+(b==100?'':"+");

}

document.write(c);

document.write("<br>");

m=0;

for(var a=1;a<=100;a++){

c=c+a+(a==100?'':"+");

m+=a;

}

document.write(c+"="+m);

</script>

</html>

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!