diff options
Diffstat (limited to 'part4/blog/utils/list_helper.js')
-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 +} |