Skip to content

Exercises completed #7

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 5 commits into
base: master
Choose a base branch
from
Open

Exercises completed #7

wants to merge 5 commits into from

Conversation

NiyazGaripov
Copy link

No description provided.

Copy link
Member

@tshemsedinov tshemsedinov left a comment

Choose a reason for hiding this comment

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

Ternary operator is good in expressions but not instead of if statement

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

const removeElement = (array, item) => {
// Remove item from array modifying original array
const index = array.indexOf(item);
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.

Use if statement instead

Copy link
Author

@NiyazGaripov NiyazGaripov Nov 27, 2019

Choose a reason for hiding this comment

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

Thank you!
Done.

// Remove multiple items from array modifying original array
for (const item of items) {
const index = array.indexOf(item);
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.

Ditto

Copy link
Author

Choose a reason for hiding this comment

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

Done.

const unique = array => {
const newArray = [];
for (const item of array) {
!newArray.includes(item) ? newArray.push(item) : array;
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

Copy link
Author

Choose a reason for hiding this comment

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

Done.

const difference = (array1, array2) => {
const newArray = [];
for (const item of array1) {
!array2.includes(item) ? newArray.push(item) : 0;
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

Copy link
Author

Choose a reason for hiding this comment

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

Done.

0xEG pushed a commit to 0xEG/Arrays that referenced this pull request Aug 19, 2022
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