-
Notifications
You must be signed in to change notification settings - Fork 0
/
eloquent-2.js
70 lines (50 loc) · 951 Bytes
/
eloquent-2.js
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
function answer1() {
var hashes = "";
for(var i = 0; i < 7; i++) {
hashes += "#";
console.log(hashes);
}
}
function answer2() {
for (var i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
console.log("FizzBuzz");
} else if (i % 3 == 0) {
console.log("Fizz");
} else if (i % 5 == 0) {
console.log("Buzz");
} else {
console.log(i);
}
}
}
function answer3() {
var gridSize = 64;
var grid = "";
for (var i = 1; i <= gridSize; i++) {
if (i % 2 == 0) {
var innerGridCount = 1;
while (innerGridCount <= gridSize) {
if(innerGridCount % 2 == 0) {
grid += "#";
} else {
grid += " ";
}
innerGridCount++;
}
grid += "\n";
} else {
var innerGridCount = 1;
while (innerGridCount <= gridSize) {
if(innerGridCount % 2 == 0) {
grid += " ";
} else {
grid += "#";
}
innerGridCount++;
}
grid += "\n";
}
}
console.log(grid);
}