-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
77 lines (51 loc) · 2.14 KB
/
Copy pathapp.js
File metadata and controls
77 lines (51 loc) · 2.14 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
$(document).ready(function(e) {
$(".btn-submit").on('click', function() {
//reset input
$('tr').remove();
//get input
inputNumber($("#input").val());
});
//one named function
var inputNumber = function(number) {
//Prevent Browser Destruction
if (+number > 777) {
$("#myModal").modal("show");
$(".modal-body").html("Really? <strong>" + number + "</strong> is a bit too big there sparky! Numbers are cool and all but that is just a bit ridiculous.");
}
//check to see if it is a decimal
else if (number % 1 != 0) {
$("#myModal").modal("show");
$(".modal-body").html("Really? <strong>" + number + "</strong> is not a whole number. I only deal in big numbers jerky! Try again!!!!");
}
//is the input blank??
else if (number == "") {
$("#myModal").modal("show");
$(".modal-body").html("Um... Please put in a number there sailor!");
}
//is the input blank??
else if (number == "0") {
$("#myModal").modal("show");
$(".modal-body").html("Sorry, Zero is going to output zero items... Nice try there buckaroo!");
} else {
//Loop it baby!
for (var i = 1; i <= number; i++) {
//if divisible by 15 - Why do I need to put divisible by 15 first for it to work?
if (i % 15 === 0) {
$(".list").append("<tr class='danger'><td><strong><span class='glyphicon glyphicon-star'></span> Fizz Buzz</strong></td></tr>");
}
//if divisibkle by 3
else if (i % 3 === 0) {
$(".list").append("<tr class='warning'><td>Fizz</td></tr>");
}
//if divisible by 5
else if (i % 5 === 0) {
$(".list").append("<tr class='success'><td>Buzz</td></tr>");
}
//if divisible by 3 and 5
else {
$(".list").append("<tr><td>" + i + "</td></tr>");
}
}
}
};
});