Skip to content

Tasks done #5

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

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

Tasks done #5

wants to merge 1 commit into from

Conversation

gidra5
Copy link

@gidra5 gidra5 commented Nov 25, 2019

No description provided.

@@ -1,7 +1,8 @@
'use strict';

const removeElements = (array, ...items) => {
// Remove multiple items from array modifying original array
for (const item of items)
array.includes(item) ? array.splice(array.indexOf(item), 1) : array;
Copy link
Member

Choose a reason for hiding this comment

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

Remove ternary to improve readability.

// Remove item from array modifying original array
};
const removeElement = (array, item) =>
(array.includes(item) ? array.splice(array.indexOf(item), 1) : array);
Copy link
Member

Choose a reason for hiding this comment

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

Remove ternary to improve readability.

const unique = array => {
const na = [];

array.forEach(i => {
Copy link
Member

Choose a reason for hiding this comment

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

Use for..of here, it's much faster and suitable in this case.

Copy link
Author

Choose a reason for hiding this comment

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

I thought I need to use Array functions mostly, so decided to use forEach

const difference = (array1, array2) => {
const na = [];

array1.forEach(i => {
Copy link
Member

Choose a reason for hiding this comment

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

Use for..of here.

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