Menu
Coddy logo textTech

22. Fizz Buzz

Lesson 23 of 31 in Coddy's 30 Days of Logic Building in Javascript course.

challenge icon

Challenge

Easy

Write a function that returns a string, such as, For multiples of 3, print "Fizz" instead of the number. For multiples of 5, print "Buzz." For numbers that are multiples of both 3 and 5, print "FizzBuzz."

  • Input: <strong>15</strong>
  • Expected Output: <strong>"1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz"</strong>

Note

1. you need to return all as string

2. don't forgot spaces

Try it yourself

function fizzBuzz(n) {
    // write your code below
    
}

All lessons in 30 Days of Logic Building in Javascript