-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathactivity-fizzbuzz.html
79 lines (67 loc) · 3.11 KB
/
activity-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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html>
<head>
<title>AC Workshop - Activity: Fizz Buzz</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<div class="container">
<div class="container-inner">
<div class="left-sidebar">
<div class="home-anchor">
<h3><a href="index.html">Intro to Programming with JavaScript</a></h3>
</div>
<div class="navigation-links">
<div class="navigation-link-item"><a href="activity-logging.html">Activity: Logging</a></div>
<div class="navigation-link-item"><a href="lecture-variables.html">Lecture: Variables</a></div>
<div class="navigation-link-item"><a href="activity-variables.html">Activity: Variables</a></div>
<div class="navigation-link-item"><a href="lecture-arrays.html">Lecture: Arrays</a></div>
<div class="navigation-link-item"><a href="activity-arrays.html">Activity: Arrays</a></div>
<div class="navigation-link-item"><a href="lecture-conditionals.html">Lecture: Conditionals</a></div>
<div class="navigation-link-item"><a href="activity-conditionals.html">Activity: Conditionals</a></div>
<div class="navigation-link-item"><a href="assignment-webproposal.html">Assignment: Web App Proposal</a></div>
<div class="navigation-link-item"><a href="lecture-loops.html">Lecture: Loops</a></div>
<div class="navigation-link-item"><a href="activity-arraysadvanced.html">Activity: Arrays (Advanced)</a></div>
<div class="navigation-link-item"><a href="lecture-functions.html">Lecture: Functions</a></div>
<div class="navigation-link-item"><a href="activity-functions.html">Activity: Functions</a></div>
<div class="navigation-link-item"><strong><em><a href="activity-fizzbuzz.html">Activity: Fizz Buzz</a></em></strong></div>
<div class="navigation-link-item"><a href="teamchallenge.html">Team Challenge</a></div>
</div>
</div>
<div class="content">
<h1>Activity: Fizz Buzz</h1>
<p>
Write a program that logs the numbers from 1 to 100. But for multiples of three log "Fizz" instead of that number, and for the multiples of five log "Buzz" instead of that number. For numbers which are multiples of both three and five log "FizzBuzz" instead. <i>Hint: what operator can we use to detect if a number is divisible by another number? How did we do even/odd?</i>
</p>
<pre><code>// Example output: for 1 - 16
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16</code></pre>
<h2>Clean Code Challenge:</h2>
<p>
What if you want to log the numbers from 1 to 1000? How can we write our program in such a way that changing the range changes our code minimally? <i>Hint: put it in a variable!</i>
</p>
<p>
This is a question they ask in interviews! Loops, conditionals, and simple math are important in almost every program you will ever write.
</p>
</div>
</div>
</div>
</body>
</html>