completed 4.4
This commit is contained in:
parent
a41907fe4b
commit
160402f147
3 changed files with 58 additions and 0 deletions
|
|
@ -15,8 +15,21 @@ const listHelper = (posts) => {
|
|||
return 1;
|
||||
};
|
||||
|
||||
const totalLikes = (posts) => {
|
||||
if (!posts) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const likeCount = posts
|
||||
.map((post) => post.likes)
|
||||
.reduce((cum, value) => cum + value, 0);
|
||||
|
||||
return likeCount;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
reverse,
|
||||
average,
|
||||
listHelper,
|
||||
totalLikes,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue