Advertisement
AHMED1970

JavaScript Loops

Feb 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. JavaScript Loops
  2. Loops are handy, if you want to run the same code over and over again, each time with a different value.
  3.  
  4. Often this is the case when working with arrays:
  5.  
  6. Instead of writing:
  7. text += cars[0] + "<br>";
  8. text += cars[1] + "<br>";
  9. text += cars[2] + "<br>";
  10. text += cars[3] + "<br>";
  11. text += cars[4] + "<br>";
  12. text += cars[5] + "<br>";
  13.  
  14. You can write:
  15. for (i = 0; i < cars.length; i++) {
  16.     text += cars[i] + "<br>";
  17. }
  18. download file on mediafire    http://ow.ly/QbeG309bTYJ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement