Skip to content

Commit 2f33966

Browse files
committed
example1, code for reduce() fix: #11
1 parent f91585e commit 2f33966

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

All Lessons/reduceExample1.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//find the sum of all the number inside an array
2+
const arr = [5, 1, 3, 2, 6];
3+
4+
const output = arr.reduce(function (acc, curr) {
5+
acc = acc+curr;
6+
return acc;
7+
}, 0);
8+
9+
console.log(output);

index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ <h1>Hello JavaScript</h1>
2121
<!-- <script src="/All Lessons/eventLoop.js"></script> -->
2222
<!-- <script src="/All Lessons/optimizedHigherOrderFunction.js"></script> -->
2323
<!-- <script src="/All Lessons/filter.js"></script> -->
24-
<script src="/All Lessons/filterExample3.js"></script>
24+
<!-- <script src="/All Lessons/filterExample3.js"></script> -->
25+
<script src="/All Lessons/reduceExample1.js"></script>
2526

2627

2728
</body>

0 commit comments

Comments
 (0)