re: Fizz Buzz in Every Language VIEW POST

FULL DISCUSSION
 

I know this must be very basic, but it's the first time I'm ever doing this.
Here's my implementation using JavaScript, printed into an HTML element :D

<p id="target"></p>
let target = document.getElementById("target");

for(let i = 1; i <= 100; i++) {
  if( i % 5 == 0 && i % 3 == 0 ) {
    target.innerHTML += "FizzBuzz<br>";
  } else if( i % 5 == 0 ) {
    target.innerHTML += "Fizz<br>";
  } else if( i % 3 == 0) {
    target.innerHTML += "Buzz<br>";
  } else {
    target.innerHTML += i + "<br>";
  }
}
code of conduct - report abuse