Skip to content

Commit 656ef56

Browse files
committed
Solves step 2-2
1 parent 69c7ee0 commit 656ef56

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

Week3/homework/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,13 @@
88
</head>
99
<body>
1010
<script src="step2-1.js"></script>
11+
<script src="step2-2.js"></script>
12+
<script src="step2-3.js"></script>
13+
<script src="step2-4.js"></script>
14+
<script src="step2-5.js"></script>
15+
<script src="step2-6.js"></script>
16+
<script src="step2-7.js"></script>
17+
<script src="step3-bonus.js"></script>
18+
<script src="step3.js"></script>
1119
</body>
1220
</html>

Week3/homework/step2-2.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
'use strict';
22

33
function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) {
4-
const numbers = [];
4+
const numbers = [...Array(stopIndex - startIndex + 1).keys()].map(x => x + startIndex);
5+
console.log(numbers);
56

6-
// Replace this comment and the next line with your code
7-
console.log(startIndex, stopIndex, threeCallback, fiveCallback, numbers);
7+
numbers.forEach(number => {
8+
if (number % 3 === 0) threeCallback(number);
9+
if (number % 5 === 0) fiveCallback(number);
10+
});
811
}
912

1013
function sayThree(number) {
11-
// Replace this comment and the next line with your code
12-
console.log(number);
14+
console.log(`${number} is divisible by 3 🧮`);
1315
}
1416

1517
function sayFive(number) {
16-
// Replace this comment and the next line with your code
17-
console.log(number);
18+
console.log(`${number} is divisible by 5 🧮`);
1819
}
19-
2020
threeFive(10, 15, sayThree, sayFive);
21+
threeFive(9, 22, sayThree, sayFive);
2122

2223
// Do not change or remove anything below this line
23-
module.exports = threeFive;
24+
module.exports = threeFive;

0 commit comments

Comments
 (0)