forked from MUSA611-CPLN692-spring2019/cpln692-week3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart2-fizzbuzz.html
54 lines (37 loc) · 956 Bytes
/
part2-fizzbuzz.html
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
/* =====================
# Lab 1, Part 2 — FizzBuzz
## Introduction
Write a program that uses console.log to print the numbers from 1 to 100.
For multiples of three, print "Fizz" instead of the number. For multiples
of five, print "Buzz" instead of the number. For numbers which are multiples
of both three and five, print "FizzBuzz".
Believe it or not, this is a common programming challenge in job interviews.
===================== */
/* =====================
Start code
===================== */
var num = []
for (i=1; i<=100; i++){
if(i%15===0){
num.push('FizzBuzz');
} else if (i%5===0){
num.push('Buzz');
} else if (i%3===0){
num.push('Fizz');
} else {
num.push(i)
}
}
console.log(num);
/* =====================
End code
===================== */
</script>
</body>
</html>