Created
January 20, 2020 15:00
-
-
Save deepakshrma/afc7b9fd3288ee2f6f9d466c37153c2e to your computer and use it in GitHub Desktop.
Weird Part: How to break the LOOP in JavaScript
This file contains hidden or 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 | |
function howMany(selectObject) { | |
let numberSelected = 0; | |
for (let i = 0; i < selectObject.options.length; i++) { | |
if (selectObject.options[i].selected) { | |
numberSelected++; | |
} | |
} | |
return numberSelected; | |
} | |
// Do While | |
let i = 0; | |
do { | |
i += 1; | |
console.log(i); | |
} while (i < 5); | |
// While | |
let n = 0; | |
let x = 0; | |
while (n < 3) { | |
n++; | |
x += n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment