completed 4.4

This commit is contained in:
counterweight 2025-06-04 23:47:43 +02:00
parent a41907fe4b
commit 160402f147
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 58 additions and 0 deletions

View file

@ -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,
};