Conversation
marciaga
left a comment
There was a problem hiding this comment.
Great job! Just one comment below. Also, note that your text editor changed double quotes to single quotes. If that happened (and it really shouldn't, because most teams will have linter and Prettier configurations), you wouldn't want to commit those changes.
| const countTotalLikes = (likedData) => { | ||
| let likedHeart = '❤️' | ||
| let numberOfHearts = 0 | ||
| return likedData.reduce((totalLikes, chat) => { |
There was a problem hiding this comment.
Nice use of .reduce here! A simpler version that just counts likes would be preferable since it's easier to see what's going on in the function and adhering to the single-purpose function paradigm is a good goal. Then you could avoid formatting the heart emoji string in the reduce and just do it in the JSX itself. You could also avoid declaring variables outside the reduce function...something like:
return likedData.reduce((totalLikes, chat) => chat.liked ? totalLikes + 1 : totalLikes, 0);so that function would return a count like how it's named. Then you can assign it to a variable like you already have on line 31 use it in the JSX like
<p> {`${countLikes} ❤️s`}</p>
No description provided.