How do I get rid of the numbers that are stuck to "Fizz" and "Buzz" on this FizzBuzz challenge from the book Eloquent Javascript. Only clues no full answers

My program comes up with all the numbers from 1 to 100 with the words fizz and buzz appearing on every multiple of 3 and 5 but I’m trying to get rid of the numbers that stay glued on fizz and buzz. I don’t know what I should do next to completely get a rid of them. Here’s what I wrote

var emptyString = "";

for (i = 1; i < 101; i++) {

	if (i % 3 === 0) {
		i % 3 === 0;
		emptyString += "Fizz";
	} else if (i % 5 === 0) {
		i % 5 === 0;
		emptyString += "Buzz";

	emptyString += i + "<br>";

document.getElementById("demo").innerHTML = emptyString;

Here’s what comes up but obviously I’m only putting down 15 numbers for this


The question for this challenge is page 38 -

Only clues no full answers

First thing.

What’s the purpose of these lines?


You need to check if the number is both divisible by 3 and 5 and output fizzbuzz.

First of all like shimphillip said I don’t see the purpose of the extra i%3 === 0; and i%5 ===0; either.

And after reading the problem from the book it tell to use the console.log instead of the html. But if you wanted to do this like you are doing.What you could do is put the empryString += 1 + “
”; inside a else statement that way if the other ones are true it won’t print that number. And you should also put <br> after both “Buzz” and “Fizz”

I’m new to all of this and I don’t know what I was doing there but it the program still worked to a certain degree which is why I left it on thinking it was useful.

I have solved the challenge everyone. I restarted completely and then took some of your guys advice. Thank-you shrimphilip and sharif15.