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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy