Skip to content

Commit fe3158e

Browse files
committed
All Javascript2 exercises and projects completed
1 parent f68d570 commit fe3158e

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Week3/homework/js-exercises/lotteryMachine.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
"use strict"
22
function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) {
33
const numbers = [];
4-
// make array
5-
// start at beginning of array and check if you should call threeCallback or fiveCallback or go on to next
4+
5+
for (let n = startIndex; n < stopIndex; n++) {
6+
numbers.push(n);
7+
}
8+
9+
numbers.forEach(n => {
10+
if (n % 3 === 0) {
11+
threeCallback();
12+
}
13+
else if (n % 5 === 0) {
14+
fiveCallback();
15+
}
16+
})
17+
}
18+
function sayThree() {
19+
console.log("three");
20+
}
21+
function sayFive() {
22+
console.log("five");
623
}
724

825
threeFive(10, 15, sayThree, sayFive);
9-
10-
// Should create an array [10,11,12,13,14,15]
11-
// and call sayFive, sayThree, sayThree, sayFive

0 commit comments

Comments
 (0)