Create a FizzBuzz Function
Easy
Write a function called "fizzBuzz" that takes a number as input and returns: - "Fizz" if the number is divisible by 3 - "Buzz" if the number is divisible by 5 - "FizzBuzz" if the number is divisible by both 3 and 5 - The number itself as a string if none of the above conditions are met
Examples
Input:
fizzBuzz(3)
Expected Output:
"Fizz"
Input:
fizzBuzz(5)
Expected Output:
"Buzz"
Input:
fizzBuzz(15)
Expected Output:
"FizzBuzz"
Input:
fizzBuzz(7)
Expected Output:
"7"
Constraints
- Input will always be a positive integer
- Return a string, not a number
- Handle edge cases appropriately
Submit your solution to check if it passes all test cases
JavaScript Editor
JavaScript
Test Results
Run your code to see test results
JavaScript Console
// Console output will appear here
Create a FizzBuzz Function
Easy
Write a function called "fizzBuzz" that takes a number as input and returns: - "Fizz" if the number is divisible by 3 - "Buzz" if the number is divisible by 5 - "FizzBuzz" if the number is divisible by both 3 and 5 - The number itself as a string if none of the above conditions are met
Examples
Input:
fizzBuzz(3)
Expected Output:
"Fizz"
Input:
fizzBuzz(5)
Expected Output:
"Buzz"
Input:
fizzBuzz(15)
Expected Output:
"FizzBuzz"
Input:
fizzBuzz(7)
Expected Output:
"7"
Constraints
- Input will always be a positive integer
- Return a string, not a number
- Handle edge cases appropriately
Submit your solution to check if it passes all test cases
JavaScript Editor
JavaScript
Test Results
Run your code to see test results
JavaScript Console
// Console output will appear here