Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2cc4f0a

Browse files
authored
Update Use the reduce Method to Analyze Data.md
1 parent 6f52311 commit 2cc4f0a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎Functional Programming/Use the reduce Method to Analyze Data.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,18 @@ let averageRating = watchList.reduce((accumulator, current) => {
148148
}
149149
return accumulator
150150
},0)/movieCount
151+
152+
========================
153+
154+
function getRating(watchList){
155+
// Only change code below this line
156+
// Only change code below this line
157+
let movieCount = 0
158+
var averageRating = watchList.filter(fItem => fItem.Director === 'Christopher Nolan').reduce((acc, curr) => {
159+
let total = acc + Number(curr.imdbRating)
160+
movieCount++;
161+
return total
162+
}, 0)
163+
// Only change code above this lin
164+
return averageRating / movieCount;
165+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /