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

Who doesnt have a pair answer #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Who doesnt have a pair answer #15

wants to merge 1 commit into from

Conversation

StudentDawid
Copy link

#5 Answer

Copy link

@bear-in-a-box bear-in-a-box left a comment

Choose a reason for hiding this comment

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

This algorithm needs an explanation on why it's working. JSDocs with typings for better writing experience would be great to see as well.

const tmp = [1, 2, 3, 4, 5, 4, 3, 2, 1];
const tmpAnswer = 5

const aloneAtParty = (tmp) => {

Choose a reason for hiding this comment

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

Missing JSDocs on parameter and return typing

const tmpAnswer = 5

const aloneAtParty = (tmp) => {
const a = tmp.reduce((acc, e) => {return acc+e}, 0);

Choose a reason for hiding this comment

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

There's no need to do {return X} here. Instead, (acc, e) => acc + e would be sufficient. Also, we don't know what "a" variable name means.


const aloneAtParty = (tmp) => {
const a = tmp.reduce((acc, e) => {return acc+e}, 0);
const b = [...new Set(tmp)].reduce((acc, e) => {return acc+e}, 0);

Choose a reason for hiding this comment

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

Same thing regarding variable naming and code styling as above.

const aloneAtParty = (tmp) => {
const a = tmp.reduce((acc, e) => {return acc+e}, 0);
const b = [...new Set(tmp)].reduce((acc, e) => {return acc+e}, 0);
return b-(a-b);

Choose a reason for hiding this comment

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

This needs a little bit of an explanation comment.

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