-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfizzbuzz.html
More file actions
56 lines (47 loc) · 1.38 KB
/
fizzbuzz.html
File metadata and controls
56 lines (47 loc) · 1.38 KB
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>FIZZ BUZZ</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
</head>
<body>
<a href="#" id="go">Fizz the Buzz</a>
<div id="theFizzBuzz"></div>
<script language="javascript">
function Buzz() {
var $display = $('#theFizzBuzz');
for (iterator = 1; iterator <= 100; iterator++) {
var extra = '';
var yesFizz = iterator % 3 == 0;
var yesBuzz = iterator % 5 == 0;
if (yesFizz) {
extra = extra + ' Fizz';
}
if (yesBuzz) {
if (!yesFizz) {
extra = extra + ' ';
}
extra = extra + 'Buzz';
}
$display.append('<p>' + iterator + extra + '</p>');
}
}
$(document).ready(function () {
$('#go').click(function () {
var $display = $('#theFizzBuzz');
var currentGoText = $('#go').text();
var rere = (currentGoText.match(/RE/g) || []).length;
$display.empty();
Buzz();
if(rere < 10) {
$('#go').text('RE-' + currentGoText);
}
else {
$('#go').text("Seriously? Haven't you pressed this enough yet?");
}
return false;
});
});
</script>
</body>
</html>