Skip to content

Conversation

MaksGovor
Copy link

No description provided.

@@ -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;
Copy link
Member

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

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;
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

Use code block 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