-
Notifications
You must be signed in to change notification settings - Fork 0
/
fizzbuzz.js
31 lines (31 loc) · 1.03 KB
/
fizzbuzz.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function run() {
var column = document.getElementById('end');
var rangelow = document.getElementById('range1').value;
var rangehigh = document.getElementById('range2').value;
column.innerHTML = ""
for (var i=rangelow; i<=rangehigh; i++) {
if (i % 3 === 0 && i % 5 === 0) {
column.innerHTML += " fizzbuzz ";
} else if (i % 3 === 0) {
column.innerHTML += " fizz ";
} else if (i % 5 === 0) {
column.innerHTML += " buzz ";
} else {
column.innerHTML += " " + i + " ";
}
}
}
function run2() {
var column2 = document.getElementById('end2');
var num = document.getElementById('num1').value;
column2.innerHTML = ""
if (num % 3 === 0 && num % 5 === 0) {
column2.innerHTML += " fizzbuzz ";
} else if (num % 3 === 0) {
column2.innerHTML += " fizz ";
} else if (num % 5 === 0) {
column2.innerHTML += " buzz ";
} else {
column2.innerHTML += " " + num + " ";
}
}