for loop:
How many times the script should
run then we used for loop.
Syntax:
for (i=0;i<=10;i++){ //code }
while loop:
The while loop loops through a
block of code while a specified condition is true.
Syntax:
int i=0;
while (i<=10){
i++;
}
JavaScript Code:
<script language="javascript">
var i=0; while (i<=5) { document.write("The number is: " + i); document.write(", "); i++; }
</script>
No comments:
Post a Comment