-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloopy.py
More file actions
24 lines (20 loc) · 784 Bytes
/
loopy.py
File metadata and controls
24 lines (20 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# We will be writing a program that prints the numbers from 100 to 200 to the console, with three exceptions:
# If the number is a multiple of 3, print the string "Loopy" instead of the number.
# If the number is a multiple of 4, print the string "Lighthouse" instead of the number.
# If the number is a multiple of both 3 and 4, print the string "LoopyLighthouse" instead of the number.
# By print, we are referring to console.log.
const NUMBER = 200;
const loopy = (number) => {
for (let i = 100; i <= number; i++) {
if (i % 3 === 0 && i % 4 === 0) {
console.log("LoopyLighthouse");
} else if (i % 3 === 0) {
console.log("Loopy");
} else if (i % 4 === 0) {
console.log("Lighthouse");
} else {
console.log(i);
}
}
};
loopy(NUMBER);