Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //While Loop
- /*
- Syntax
- while(condition){
- statment ;
- }
- */
- var i=0;
- while(i<=10){
- console.log(i);
- i++
- }
- function generateYears(start,end){
- var years =start;
- document.write("<select>");
- while(years <= end){
- document.write("<option value= \"" +years+"\">" + years +"</option>");
- years++;
- }
- document.write("</select>");
- }
- generateYears(1900,2018);
- //DO WHILE
- /* SYNTAX
- do{
- statment;
- }while(condition)
- */
- var k=0;
- do{
- console.log(k);
- k++;
- }while(k <= 20);
- function generateYears(start,end){
- var years =start;
- document.write("<select>");
- do{
- document.write("<option value= \"" +years+"\">" + years +"</option>");
- years++;
- }while(years <= end)
- document.write("</select>");
- }
- generateYears(1900,2018);
Add Comment
Please, Sign In to add comment