-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
base: master
Are you sure you want to change the base?
Tasks done #5
Conversation
@@ -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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use for..of here.
No description provided.