Created
October 20, 2014 05:43
-
-
Save lizlongnc/4da2d50c2dc9222b8534 to your computer and use it in GitHub Desktop.
JS break in for loop
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
var age = Number(prompt('What is your age? ', ' ')); | |
var string = ''; | |
for (var counter = 1; counter < age; counter++) { | |
string += 'Happy Birthday\n'; | |
if (counter % 7 === 0) { | |
break; | |
} | |
} | |
alert(string); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment