Skip to content

practice-js-basics-arrays done#144

Open
satoshi300 wants to merge 9 commits intodevmentor-pl:masterfrom
satoshi300:master
Open

practice-js-basics-arrays done#144
satoshi300 wants to merge 9 commits intodevmentor-pl:masterfrom
satoshi300:master

Conversation

@satoshi300
Copy link
Copy Markdown

Fixed Task 05. in the previous solution to the task, I did not use the filter() and reduce() methods.

Copy link
Copy Markdown
Owner

@devmentor-pl devmentor-pl left a comment

Choose a reason for hiding this comment

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

Michale,

Praktycznie idealnie! 🥇
Zajrzyj tylko do komentarza z ostatniego zadania :)

Comment thread 01/app.js
console.log(users[0]);
console.log(users[2]);
console.log(users[4]);
console.log(users.length); No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

Comment thread 02/app.js
});

const lastIndex = randomArray.length-1;
console.log('Ostatni element tablicy to: ' + randomArray[lastIndex]); No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

Comment thread 03/app.js
}
}

console.log(oddNumbers); No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

Comment thread 04/app.js

function diffBetweenYears(element) {
return presentYear - element;
} No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

Comment thread 05/app.js Outdated
const numbers = [1, 2, 3, 4, 5, 6, 7]; No newline at end of file
const numbers = [1, 2, 3, 4, 5, 6, 7];
const evenNumbers = numbers.filter((item) => item % 2 === 0);
const sum = evenNumbers.reduce((item, x) => item + x)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Dobrą praktyka jest też wskazanie od jakiej wartości zaczynamy liczenie tj. evenNumbers.reduce((item, x) => item + x, 0) - jeśli tablica byłaby pusta to przy Twoim rozwiązaniu będzie błąd (nie ma pierwszego elemntu), przy zaproponowanym przeze mnie będzie po prostu zwrócone 0 :)

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