Loop In javascript 6/8

Loop In javascript
Loops are handy, if you want to run the same code over and over again, each time with a different value.

How to Implement the code
1: Open the Nodpad
2: Copy code and paste in Nodpad
3:  Save the flie "loop.js"

<!DOCTYPE html>
<html>
<body>

<p>Click the button to loop through a block of code five times.< /p>
<button onclick="myFunction()">Try it< /button>
<p id="demo">< /p>

<script>
function myFunction()
{
  var x="",i;
  for (i=0;i<5;i++)
  {
    x=x + "The number is " + i + "< br>";
  }
  document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>
Loop In javascript 6/8 Loop In javascript 6/8 Reviewed by Abdul hanan on 11:34:00 Rating: 5
Powered by Blogger.