Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snow leopards - Aretta B. #129

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

snow leopards - Aretta B. #129

wants to merge 4 commits into from

Conversation

arettab
Copy link

@arettab arettab commented Jan 5, 2023

No description provided.

Copy link

@marciaga marciaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants