Last active
October 2, 2017 09:38
-
-
Save jialinhuang00/708c311e99a96bb11063a12938358279 to your computer and use it in GitHub Desktop.
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
/*----------------------------------------------------------------------------- | |
1.check the multiple | |
2.the fifteen's case must be first. | |
the reference is from UdemyCourse: LearningAlgorithmsInJavascriptFromScratch | |
-----------------------------------------------------------------------------*/ | |
// 15X ->> 'FizzBuzz' | |
// 5X ->> 'buzz' | |
// 3X ->> 'fizz' | |
function fizbuz(n) { | |
var i; | |
for (i = 0; i < n; i++) { | |
if (i % 15 === 0) { | |
console.log("FizzBuzz"); | |
} else if (i % 3 === 0) { | |
console.log("fizz"); | |
} else if (i % 5 === 0) { | |
console.log("buzz"); | |
} else console.log(i); | |
} | |
} | |
fizbuz(49); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment