From edde5700793e68979d13612a1f9e87d96802d8cd Mon Sep 17 00:00:00 2001 From: Inna Nedohybchenko Date: Thu, 4 Jun 2026 15:36:50 +0300 Subject: [PATCH 1/5] add 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..ae614fa1c 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,34 @@ 'use strict'; -// write code here +const list = document.querySelector('ul'); + +function getSalary(item) { + return Number(item.dataset.salary.replaceAll(',', '').replace('$', '')); +} + +function sortList(ul) { + const items = [...ul.children]; + + items.sort((a, b) => { + return getSalary(b) - getSalary(a); + }); + ul.append(...items); +} + +function getEmployers(ul) { + const items = [...ul.children]; + const employers = []; + + items.forEach((item) => { + employers.push({ + name: item.textContent.trim(), + position: item.dataset.position, + salary: getSalary(item), + age: Number(item.dataset.age), + }); + }); + + return employers; +} +sortList(list); +getEmployers(list); From 0264f3fe33ebd757045f35b52eeef2cbf63bd5f4 Mon Sep 17 00:00:00 2001 From: Inna Nedohybchenko Date: Thu, 4 Jun 2026 15:50:01 +0300 Subject: [PATCH 2/5] change 1 --- src/scripts/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index ae614fa1c..cf8fffd38 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -15,13 +15,13 @@ function sortList(ul) { ul.append(...items); } -function getEmployers(ul) { +function getEmployeers(ul) { const items = [...ul.children]; const employers = []; items.forEach((item) => { employers.push({ - name: item.textContent.trim(), + name: item.querySelector('.name').textContent.trim(), position: item.dataset.position, salary: getSalary(item), age: Number(item.dataset.age), @@ -31,4 +31,4 @@ function getEmployers(ul) { return employers; } sortList(list); -getEmployers(list); +getEmployeers(list); From 06e7250dc7f8fe2015cb6530615cb83c34eea211 Mon Sep 17 00:00:00 2001 From: Inna Nedohybchenko Date: Thu, 4 Jun 2026 16:01:34 +0300 Subject: [PATCH 3/5] change 1 --- src/scripts/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index cf8fffd38..f8f75e54e 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -15,7 +15,7 @@ function sortList(ul) { ul.append(...items); } -function getEmployeers(ul) { +function getEmployees(ul) { const items = [...ul.children]; const employers = []; @@ -31,4 +31,4 @@ function getEmployeers(ul) { return employers; } sortList(list); -getEmployeers(list); +getEmployees(list); From 71d1a408ae9a9742933d5cc50aae3ef0c9f761a2 Mon Sep 17 00:00:00 2001 From: Inna Nedohybchenko Date: Thu, 4 Jun 2026 16:10:29 +0300 Subject: [PATCH 4/5] change 3 --- src/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index f8f75e54e..91df3c612 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -21,7 +21,7 @@ function getEmployees(ul) { items.forEach((item) => { employers.push({ - name: item.querySelector('.name').textContent.trim(), + name: item.children[0].textContent.trim(), position: item.dataset.position, salary: getSalary(item), age: Number(item.dataset.age), From cec141a5b76eecb4f072422692d1e9161596aec6 Mon Sep 17 00:00:00 2001 From: Inna Nedohybchenko Date: Thu, 4 Jun 2026 16:17:55 +0300 Subject: [PATCH 5/5] change 4 --- src/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index 91df3c612..63d9d0dbc 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -21,7 +21,7 @@ function getEmployees(ul) { items.forEach((item) => { employers.push({ - name: item.children[0].textContent.trim(), + name: item.textContent.trim(), position: item.dataset.position, salary: getSalary(item), age: Number(item.dataset.age),