-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloopsLighthouse.js
37 lines (32 loc) · 922 Bytes
/
loopsLighthouse.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
// Fixed
// for (var x = 100; x <= 200;++x) {
// if (x % 3 === 0 && x % 4 === 0) {
// console.log("LoopyLighthouse");
// } else if (x % 3 === 0){
// console.log("Loopy");
// } else if (x % 4 === 0) {
// console.log("Lighthouse");
// } else {
// console.log(x);
// }
// }
// make more legible
for (i = 100; i <=200; i++) {
answer = i % 3 === 0 && i % 4 === 0 ?
"LoopyLighthouse" : i % 3 === 0 ?
"Loopy" : i % 4 === 0 ?
"Lighthouse" : i;
console.log(answer);
}
// original student code
// for (var x = 100; x <= 200;++x) {
// if (x % 3 === 0){
// console.log("Loopy");
// } else if (x % 4 === 0) {
// console.log("Lighthouse");
// } else if (x % 3 === 0 && x % 4 === 0) {
// console.log("LoopyLighthouse");
// } else {
// console.log(x);
// }
// }