I'm trying to run the FizzBuzz problem solving, it seems to be working, however when it reaches the user input number it returns undefined.
Here is my code:
const prompt = require("prompt-sync")();
let userChoice = parseInt(prompt("Please enter a number: "));
function fizzBuzz () {
for (let i=1 ; i <= userChoice; i++){
if (i % 3 === 0 && i % 5 ===0) {
console.log("FizzBuzz");
}
else if (i % 3 === 0){
console.log("Fizz");
}
else if (i % 5 === 0){
console.log("Buzz");
}
else {
console.log(i);
}
}
}
console.log(fizzBuzz(userChoice));