diff options
author | Ibrahim Mkusa <ibrahimmkusa@gmail.com> | 2023-06-19 12:40:23 -0400 |
---|---|---|
committer | Ibrahim Mkusa <ibrahimmkusa@gmail.com> | 2023-06-19 12:40:23 -0400 |
commit | 8c8249626dc3d50463d4ad89e75fb084faf46ba8 (patch) | |
tree | 503612d6763a2c3c2e13f26c619665fe148499ec /part4/blog/utils | |
parent | d9cec6010008040cc2cbbe43be1d16ebbad44e39 (diff) |
Diffstat (limited to 'part4/blog/utils')
-rw-r--r-- | part4/blog/utils/list_helper.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/part4/blog/utils/list_helper.js b/part4/blog/utils/list_helper.js index e52c23c..871bbc3 100644 --- a/part4/blog/utils/list_helper.js +++ b/part4/blog/utils/list_helper.js @@ -1,5 +1,18 @@ +const logger = require('../utils/logger.js') const dummy = (blogs) => { return 1 } -module.exports = {dummy} + +const totalLikes = (blogs) => { + likes = 0 + for (const blog of blogs) { + likes += blog.likes + } + + return likes +} + +module.exports = { + dummy, totalLikes +} |