-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFizzBuzz.html
30 lines (30 loc) · 983 Bytes
/
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fizz Buzz</title>
<!-- <script src="./FizzBuzz.js" defer></script> -->
</head>
<body>
<h1>Fizz Buzz in JavaScript</h1>
<script>
// Loop through all numbers from 1 to 100.
// If a number is divisible by 3, log “Fizz.”
// If a number is divisible by 5, log “Buzz.”
// If a number is divisible by both 3 and 5, log “Fizz Buzz.”
// If a number is not divisible by either 3 or 5, log the number.
for(let i = 1; i <= 100; i++) {
if(i % 3 == 0 && i % 5 == 0){
console.log("Fizz Buzz.");
}else if(i % 5 == 0){
console.log("Buzz.");
}else if(i % 3 == 0) {
console.log("Fizz.");
}else {
console.log(i);
}
}
</script>
</body>
</html>