Skip to content

Homework 5#4

Open
Phantom123-cloud wants to merge 17 commits into
masterfrom
homework-5
Open

Homework 5#4
Phantom123-cloud wants to merge 17 commits into
masterfrom
homework-5

Conversation

@Phantom123-cloud
Copy link
Copy Markdown
Owner

No description provided.

Comment thread 05/script.js
const arr = ["4534", "a", "bb", "sdfds", "", " ", "r4rdv-"];
const sortArr = (arr) => {
return arr.sort((a, b) => {
return a.length - b.length
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

   const lengthCheck = a.length - b.length;
    const alphaCheck = a > b ? 1 : -1;
    return lengthCheck === 0 ? alphaCheck : lengthCheck;

Comment thread 05/script.js

const averageAge = (arr) => {
const filter = arr.filter((el) => el.age > 17 && el.age < 55)
const average = (filter.map((el) => el.age)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you don't need map here
`const averageAge = (arr) => {
const filteredArr = arr.filter(
(profile) => profile.age > 17 && profile.age < 55
);
const sum = filteredArr.reduce((acc, profile) => acc + profile.age, 0);

return sum / filteredArr.length;
};`

Comment thread 05/script.js Outdated

const printPyramid = (n) => {
for (let i = 1; i <= n; i++) {
const lattice = '#'.repeat(n - i);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread 05/script.js Outdated
{
// Find the Longest Consecutive Sequence
function findLongestConsecutive(arr) {
const uniqueArr = new Set(arr);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

that's incorrect
треба знайти найдовшу послідовність а не числа по черзі

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