Menu
Coddy logo textTech

The FizzBuzz Function

Part of the Fundamentals section of Coddy's JavaScript journey — lesson 54 of 77.

challenge icon

Challenge

Easy

Add a function named fizzbuzz that gets one number (int) as an argument, and:

  • If the number is divisible by 3, return "Fizz".
  • If the number is divisible by 7, return "Buzz".
  • If the number is divisible by both 3 and 7, return "FizzBuzz".
  • If none of the above conditions are met, return the number itself in a string format.

Finally print the output of fizzbuzz(num) where num is the given input.

Try it yourself

let num = parseInt(inp); // Don't change this line

// Type your code below

All lessons in Fundamentals