Skip to content

Commit ba35e9e

Browse files
committed
reduce examaple 2, fix: #12
1 parent 2f33966 commit ba35e9e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

All Lessons/reduceExample2.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//find the maximum number of all the number inside an array
2+
const arr = [5, 1, 3, 2, 6];
3+
4+
const output = arr.reduce(function (max, curr) {
5+
if(curr > max){
6+
max=curr;
7+
}
8+
return max;
9+
}, 0);
10+
11+
console.log(output);

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ <h1>Hello JavaScript</h1>
2222
<!-- <script src="/All Lessons/optimizedHigherOrderFunction.js"></script> -->
2323
<!-- <script src="/All Lessons/filter.js"></script> -->
2424
<!-- <script src="/All Lessons/filterExample3.js"></script> -->
25-
<script src="/All Lessons/reduceExample1.js"></script>
25+
<!-- <script src="/All Lessons/reduceExample1.js"></script> -->
26+
<script src="/All Lessons/reduceExample2.js"></script>
2627

2728

2829
</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