-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Labs done #8
base: master
Are you sure you want to change the base?
Labs done #8
Conversation
@@ -1,7 +1,8 @@ | |||
'use strict'; | |||
|
|||
const removeElement = (array, item) => { | |||
// Remove item from array modifying original array | |||
const index = array.indexOf(item); | |||
return index !== -1 ? array.splice(index, 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.
This task implies modifying original array, no need to return anything, but it's ok. Not ok is to use ternary here, if statement is more relevant for this case.
@@ -1,7 +1,11 @@ | |||
'use strict'; | |||
|
|||
const removeElements = (array, ...items) => { | |||
// Remove multiple items from array modifying original array | |||
for (const i of items) { |
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.
Naming i
may confuse someone (may refer to i:Number
like in regular for loops), better use item
or element
here.
const index = array.indexOf(i); | ||
if (index !== -1) array.splice(index, 1); | ||
} | ||
return 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.
No need to return, but it's ok.
const unique = array => []; | ||
const unique = array => { | ||
const arr = []; | ||
for (const item of 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.
Use code block here.
No description provided.