Created
June 28, 2018 09:34
-
-
Save humayunahmed8/9bb29cc8d6ca5c5eab20c4dc91b23aca to your computer and use it in GitHub Desktop.
JS Loop - For, (While, Do/While, For/In)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*=====For Loop=====*/ | |
//for (variable; condition; incriment/decriment) { | |
// Your Document | |
} | |
var x; | |
for (x=56; x<=61; x++) { | |
document.write(x+'<br/>'); | |
} | |
/*=====While Loop=====*/ | |
//while (condition) { | |
// statement | |
} | |
var x = 10; | |
while(x<15){ | |
document.write('Hello World<br/>'); | |
x++; | |
} | |
/*=====Do/While Loop=====*/ | |
//do{ | |
// statement | |
//} while (condition); | |
var x = 10; | |
do{ | |
document.write('Hello World<br/>'); | |
x++; | |
} while (x<18); | |
/*=====For/In Loop=====*/ | |
//for (variable in object) { | |
// statement | |
} | |
var paragraphElement = document.getElementsByTagName('a'); | |
for(var key in paragraphElement){ | |
document.write(paragraphElement[key].innerHTML+'<br/>'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment