Beginner here, so I might not be using the correct terms to describe this. I have a for Loop, else if statement that produces the result via console.log
.
What I want to do is have those results (basic fizzbuzz problem) display on an HTML page. I have been reading high and low, and getting a little discouraged that I can't figure this out on my own. My guess is it should be something with .append
but I don't know if that's right, or what the event(?) should even be. (e.g.; .click, .hover, etc.)
Let me know if you need any more info. My head is jumbled from all the code I've gone through. Any help would be greatly appreciated!
Here is my js code:
var choice = prompt("What number should we count up to?");
for (var i = 1; i <= choice; i++) {
if (i % 15 === 0) {
console.log('FizzBuzz');
} else if (i % 3 === 0) {
console.log('Fizz');
} else if (i % 5 === 0) {
console.log('Buzz');
} else {
console.log(i);
}
}
And html:
<!DOCTYPE html>
<html>
<head>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all'>
<script src="js/jquery-1.11.1.js"></script>
<script src="js/fizzBuzz.js"></script>
<title>FizzBuzz!</title>
</head>
<body>
<ol id="log">
</ol>
</body>
</html>
The tag is a placeholder of sorts right now...