Last active
October 1, 2017 05:03
-
-
Save johndavedecano/3f9d6661455783a12f5c51345595d2e9 to your computer and use it in GitHub Desktop.
EXAMS - FIZZBUZZ
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) { | |
let returnValue = ''; | |
let isFizz = num % 3 === 0; | |
let isBuzz = num % 5 === 0; | |
returnValue = (isFizz ? 'Fizz' : '') + (isBuzz ? 'Buzz' : ''); | |
if (returnValue !== '') { | |
console.log(returnValue + ' - ' + num); | |
} | |
if ((num - 1) > 0) { | |
fizzbuzz(num - 1); | |
} | |
} | |
fizzbuzz(15); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment