Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fizzBuzz(num) {
- if ((num % 3 === 0) && (num % 5 === 0)) {
- return 'fizzbuzz';
- }
- else if (num % 3 === 0) {
- return 'fizz';
- }
- else if (num % 5 === 0) {
- return 'buzz';
- }
- else {
- return num;
- }
- // if num is divisible by 3 return 'fizz'
- // if num is divisible by 5 return 'buzz'
- // if num is divisible by 3 & 5 return 'fizzbuzz'
- // otherwise return num
- }
Add Comment
Please, Sign In to add comment