Guest User

Untitled

a guest
Feb 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. //While Loop
  2. /*
  3. Syntax
  4. while(condition){
  5. statment ;
  6. }
  7. */
  8.  
  9. var i=0;
  10. while(i<=10){
  11. console.log(i);
  12. i++
  13. }
  14.  
  15.  
  16. function generateYears(start,end){
  17. var years =start;
  18. document.write("<select>");
  19. while(years <= end){
  20. document.write("<option value= \"" +years+"\">" + years +"</option>");
  21. years++;
  22. }
  23. document.write("</select>");
  24. }
  25. generateYears(1900,2018);
  26.  
  27.  
  28. //DO WHILE
  29. /* SYNTAX
  30. do{
  31.  
  32. statment;
  33.  
  34. }while(condition)
  35. */
  36.  
  37. var k=0;
  38. do{
  39.  
  40. console.log(k);
  41. k++;
  42.  
  43. }while(k <= 20);
  44.  
  45.  
  46. function generateYears(start,end){
  47. var years =start;
  48. document.write("<select>");
  49. do{
  50. document.write("<option value= \"" +years+"\">" + years +"</option>");
  51. years++;
  52. }while(years <= end)
  53. document.write("</select>");
  54. }
  55. generateYears(1900,2018);
Add Comment
Please, Sign In to add comment