From 44a5f563fbba5a7c518c4a267f9dc9e41acd14ca Mon Sep 17 00:00:00 2001 From: Borodina Liliia Date: Wed, 11 Nov 2026 01:56:32 +0200 Subject: [PATCH 1/6] solution --- src/scripts/main.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..aaf072f23 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,34 @@ 'use strict'; -// write code here +const ul = document.querySelector('ul'); +const li = [...document.querySelectorAll('li')]; + +const changeToNum = (str) => { + return Number(str.split('$')[1].replaceAll(',', '')); +}; + +const sortList = (list) => { + return list.sort( + (el1, el2) => + changeToNum(el2.dataset.salary) - changeToNum(el1.dataset.salary), + ); +}; + +const getEmployees = (list) => { + const result = []; + + list.forEach((element) => { + result.push({ + name: element.textContent.trim(), + position: element.dataset.position, + salary: element.dataset.salary, + age: element.dataset.age, + }); + }); + + return result; +}; + +ul.append(...sortList(li)); + +getEmployees(sortList(li)); From c8f67d00d15958f6296c3e6d840ac51f3bfd3b83 Mon Sep 17 00:00:00 2001 From: Borodina Liliia Date: Wed, 11 Nov 2026 02:01:08 +0200 Subject: [PATCH 2/6] Revert "solution" This reverts commit 44a5f563fbba5a7c518c4a267f9dc9e41acd14ca. --- src/scripts/main.js | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index aaf072f23..a765fdb1d 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,34 +1,3 @@ 'use strict'; -const ul = document.querySelector('ul'); -const li = [...document.querySelectorAll('li')]; - -const changeToNum = (str) => { - return Number(str.split('$')[1].replaceAll(',', '')); -}; - -const sortList = (list) => { - return list.sort( - (el1, el2) => - changeToNum(el2.dataset.salary) - changeToNum(el1.dataset.salary), - ); -}; - -const getEmployees = (list) => { - const result = []; - - list.forEach((element) => { - result.push({ - name: element.textContent.trim(), - position: element.dataset.position, - salary: element.dataset.salary, - age: element.dataset.age, - }); - }); - - return result; -}; - -ul.append(...sortList(li)); - -getEmployees(sortList(li)); +// write code here From a7ccb6df31afca568ba67987f9ae70885637bdec Mon Sep 17 00:00:00 2001 From: Borodina Liliia Date: Wed, 11 Nov 2026 02:03:07 +0200 Subject: [PATCH 3/6] solution --- src/scripts/main.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..aaf072f23 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,34 @@ 'use strict'; -// write code here +const ul = document.querySelector('ul'); +const li = [...document.querySelectorAll('li')]; + +const changeToNum = (str) => { + return Number(str.split('$')[1].replaceAll(',', '')); +}; + +const sortList = (list) => { + return list.sort( + (el1, el2) => + changeToNum(el2.dataset.salary) - changeToNum(el1.dataset.salary), + ); +}; + +const getEmployees = (list) => { + const result = []; + + list.forEach((element) => { + result.push({ + name: element.textContent.trim(), + position: element.dataset.position, + salary: element.dataset.salary, + age: element.dataset.age, + }); + }); + + return result; +}; + +ul.append(...sortList(li)); + +getEmployees(sortList(li)); From e6c74fe81ed63299653c5f071ec7d69e72a10671 Mon Sep 17 00:00:00 2001 From: Borodina Liliia Date: Wed, 11 Nov 2026 02:04:12 +0200 Subject: [PATCH 4/6] added readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 294f077fb..ef566311b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ 1. Replace `` with your Github username in the link - - [DEMO LINK](https://.github.io/js_task_parse_list_DOM/) + - [DEMO LINK](https://LiliiaVol.github.io/js_task_parse_list_DOM/) 2. Follow [this instructions](https://mate-academy.github.io/layout_task-guideline/) - Run `npm run test` command to test your code; - Run `npm run test:only -- -n` to run fast test ignoring linter; From 6f4f51cb57ea4914f34c7d03856ee0466d8dedeb Mon Sep 17 00:00:00 2001 From: Borodina Liliia Date: Wed, 11 Nov 2026 02:18:41 +0200 Subject: [PATCH 5/6] Editted main.js --- src/scripts/main.js | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index aaf072f23..c8015ec45 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -8,27 +8,12 @@ const changeToNum = (str) => { }; const sortList = (list) => { - return list.sort( - (el1, el2) => - changeToNum(el2.dataset.salary) - changeToNum(el1.dataset.salary), + ul.append( + ...list.sort( + (el1, el2) => + changeToNum(el2.dataset.salary) - changeToNum(el1.dataset.salary), + ), ); }; -const getEmployees = (list) => { - const result = []; - - list.forEach((element) => { - result.push({ - name: element.textContent.trim(), - position: element.dataset.position, - salary: element.dataset.salary, - age: element.dataset.age, - }); - }); - - return result; -}; - -ul.append(...sortList(li)); - -getEmployees(sortList(li)); +sortList(li); From 62455ca58bb0986729d4180551d5fccc80b0ba6a Mon Sep 17 00:00:00 2001 From: Borodina Liliia Date: Wed, 11 Nov 2026 02:24:14 +0200 Subject: [PATCH 6/6] Editted main.js second time --- src/scripts/main.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index c8015ec45..c340a899f 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -7,8 +7,8 @@ const changeToNum = (str) => { return Number(str.split('$')[1].replaceAll(',', '')); }; -const sortList = (list) => { - ul.append( +const sortList = (list, ulList) => { + ulList.append( ...list.sort( (el1, el2) => changeToNum(el2.dataset.salary) - changeToNum(el1.dataset.salary), @@ -16,4 +16,20 @@ const sortList = (list) => { ); }; -sortList(li); +const getEmployees = (list) => { + const result = []; + + list.forEach((element) => { + result.push({ + name: element.textContent.trim(), + position: element.dataset.position, + salary: element.dataset.salary, + age: element.dataset.age, + }); + }); + + return result; +}; + +sortList(li, ul); +getEmployees(li);