Created
February 27, 2018 14:18
-
-
Save kmdsbng/9ec80e699de6a5d73becc8e198fd59a6 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
| function fizzbuzz(num) { | |
| for (var i = 1; i < num + 1; i++) { | |
| if(i % 15 === 0) { | |
| console.log("fizzbuzz"); | |
| continue; | |
| } | |
| if(i % 3 === 0) { | |
| console.log("fizz") | |
| continue; | |
| } | |
| if(i % 5 === 0) { | |
| console.log("buzz"); | |
| continue; | |
| } | |
| console.log(i); | |
| } | |
| } | |
| function fizzbuzzB(num) { | |
| for (var i = 1; i < num + 1; i++) { | |
| var carfizz = i + ''; | |
| var carbuzz = i + ''; | |
| var fizzCondition = carfizz.indexOf('3'); | |
| var buzzCondition = carbuzz.indexOf('5'); | |
| if((i % 3 === 0 || fizzCondition >= 0) && (i % 5 === 0 || buzzCondition >= 0)) { | |
| console.log("fizzbuzz"); | |
| continue; | |
| } | |
| if(i % 3 === 0 || fizzCondition >= 0) { | |
| console.log("fizz") | |
| continue; | |
| } | |
| if(i % 5 === 0 || buzzCondition >= 0) { | |
| console.log("buzz"); | |
| continue; | |
| } | |
| console.log(i); | |
| } | |
| } | |
| fizzbuzz(100); | |
| fizzbuzzB(100); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment