I am developing JS on a Windows machine using VS Code as my code editor. I have a fairly simple script that I worked on for the Odin Project:
let userInput = parseInt(prompt("Please enter the number you would like to FizzBuzz up to: "));
function makeNumberList(userInput) {
let numberList = []
for (let i = 0; i <= +userInput; i++) {
numberList.push(i)
}
return numberList
}
function fizzbuzz(number) {
if (!(number % 3)) {
if (!(number % 5)) {
return 'fizzbuzz'
} else {
return 'fizz'
}
} else if (!(number % 5)) {
return 'buzz'
} else {
return number
}
}
let numberList = makeNumberList(userInput)
console.log(numberList)
console.log(numberList.map(fizzbuzz))
I can execute that code in a browser by creating an index.html and inserting the code in a <script></script> html tag.
However, I can't get it to work in VS Code. I would like to be able to debug my code seamlessly on VS Code as it was executing in a brower.
I have stumbled across answers suggesting to use Node and different packages (readline, prompt, prompt-sync) - but that does not work on my side, I can't enter an input - as well as answers stating that Windows does not feature a proper prompt and I should therefore use the Windows Subsystem Linux (WSL).
How can one use VS Code on a Windows machine to debug a JS script requiring user input in a prompt?