I tried making an small fizzbuzz algorithm
function fizzbuzz(num){
for (let i = 1; i <= num; 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(20));
It works fine using console.log but now I want to build something which takes the input from a textfield and displays the output of this algorithm on the webpage itself after clicking a button. I am new to the dom and I tried document.write() but It didn't seem to work.
Thanks.