Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 196a154

Browse files
committed
change to step2
1 parent 6fe588d commit 196a154

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

Week3/homework/2-step3.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
'use strict';
22

3+
function sayThree() {
4+
console.log(3);
5+
}
6+
7+
function sayFive() {
8+
console.log(5);
9+
}
310

411
function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) {
5-
const values = [];
6-
for (var i = startIndex; i <= stopIndex; i++){
7-
values.push(i)
8-
}
9-
console.log(values);
12+
const values = [];
13+
for (var i = startIndex; i <= stopIndex; i++){
14+
values.push(i)
15+
}
16+
console.log(values);
1017

11-
for (let j = 0; j < values.length; j++){
12-
if (j % 3 === 0) {
13-
threeCallback("3");
14-
}
15-
else if (j % 5 === 0) {
16-
fiveCallback("5");
17-
}
18-
else if ((j % 3=== 0) && (j % 5 === 0)) {
19-
fiveCallback("5") && threeCallback("3");
20-
}
18+
for (let j = 0; j < values.length; j++){
19+
if ((values[j] % 3 === 0) && (values[j] % 5 === 0)) {
20+
threeCallback()
21+
fiveCallback();
2122
}
22-
}
23-
function sayThree(threeCallback) {
24-
console.log(threeCallback);
23+
else if(values[j] % 3 === 0) {
24+
threeCallback();
2525
}
26-
27-
function sayFive(fiveCallback) {
28-
console.log(fiveCallback);
26+
else if (values[j] % 5 === 0) {
27+
fiveCallback();
2928
}
29+
}
30+
}
3031

3132
threeFive(10, 15, sayThree, sayFive)

0 commit comments

Comments
 (0)