From 19a4015409b8ce661699b9c910626b4fca2b3faf Mon Sep 17 00:00:00 2001 From: Georgiy Veshchev Date: Mon, 13 Apr 2026 14:25:17 +0300 Subject: [PATCH 1/4] solution --- .github/workflows/test.yml-template | 29 +++++++++++++++++++++++++++ src/scripts/main.js | 31 ++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml-template diff --git a/.github/workflows/test.yml-template b/.github/workflows/test.yml-template new file mode 100644 index 000000000..44ac4e963 --- /dev/null +++ b/.github/workflows/test.yml-template @@ -0,0 +1,29 @@ +name: Test + +on: + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm start & sleep 5 && npm test + - name: Upload tests report(cypress mochaawesome merged HTML report) + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: report + path: reports diff --git a/src/scripts/main.js b/src/scripts/main.js index 7d4a5db04..aa19d9d75 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -357,4 +357,33 @@ const people = [ // eslint-disable-next-line no-console console.log(people); // you can remove it -// write your code here +const table = document.querySelector('.dashboard'); + +people.forEach((person) => { + const row = document.createElement('tr'); + + const selfName = document.createElement('td'); + + selfName.textContent = person.selfName; + + const gender = document.createElement('td'); + + gender.textContent = person.sex; + + const born = document.createElement('td'); + + born.textContent = person.born; + + const died = document.createElement('td'); + + died.textContent = person.died; + + const age = document.createElement('td').append(person.died - person.born); + + const century = document + .createElement('td') + .append(Math.ceil(person.died / 100)); + + row.append(selfName, age, gender, born, died, age, century); + table.append(row); +}); From 20d8fa0a9312f2bccc43eb0b85dfa8a0d5e07bc5 Mon Sep 17 00:00:00 2001 From: Georgiy Veshchev Date: Mon, 13 Apr 2026 14:32:14 +0300 Subject: [PATCH 2/4] solution 2.0 --- src/scripts/main.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index aa19d9d75..13ef489cd 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -362,28 +362,31 @@ const table = document.querySelector('.dashboard'); people.forEach((person) => { const row = document.createElement('tr'); - const selfName = document.createElement('td'); + const cellName = document.createElement('td'); - selfName.textContent = person.selfName; + cellName.textContent = person.name; - const gender = document.createElement('td'); + const cellGender = document.createElement('td'); - gender.textContent = person.sex; + cellGender.textContent = person.sex; - const born = document.createElement('td'); + const cellBorn = document.createElement('td'); - born.textContent = person.born; + cellBorn.textContent = person.born; - const died = document.createElement('td'); + const cellDied = document.createElement('td'); - died.textContent = person.died; + cellDied.textContent = person.died; - const age = document.createElement('td').append(person.died - person.born); + const cellAge = document.createElement('td'); - const century = document - .createElement('td') - .append(Math.ceil(person.died / 100)); + cellAge.textContent = person.died - person.born; + + const cellCentury = document.createElement('td'); + + cellCentury.textContent = Math.ceil(person.died / 100); + + row.append(cellName, cellGender, cellBorn, cellDied, cellAge, cellCentury); - row.append(selfName, age, gender, born, died, age, century); table.append(row); }); From e54d0ff3ac44497a9c6a6cfc8b85ae16b4849553 Mon Sep 17 00:00:00 2001 From: Georgiy Veshchev Date: Mon, 13 Apr 2026 14:40:12 +0300 Subject: [PATCH 3/4] solution 3.0 --- src/scripts/main.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index 13ef489cd..e813046cd 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -354,9 +354,6 @@ const people = [ }, ]; -// eslint-disable-next-line no-console -console.log(people); // you can remove it - const table = document.querySelector('.dashboard'); people.forEach((person) => { From 767dc777c9d3c5f2c72266b398ac1f8c57f7af10 Mon Sep 17 00:00:00 2001 From: Georgiy Veshchev Date: Mon, 13 Apr 2026 14:49:53 +0300 Subject: [PATCH 4/4] solution 4.0 --- src/scripts/main.js | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index e813046cd..262e987cf 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -356,34 +356,37 @@ const people = [ const table = document.querySelector('.dashboard'); -people.forEach((person) => { - const row = document.createElement('tr'); +if (table) { + const tableBody = table.querySelector('tbody') || table; - const cellName = document.createElement('td'); + people.forEach((person) => { + const row = document.createElement('tr'); - cellName.textContent = person.name; + const cellName = document.createElement('td'); - const cellGender = document.createElement('td'); + cellName.textContent = person.name; - cellGender.textContent = person.sex; + const cellGender = document.createElement('td'); - const cellBorn = document.createElement('td'); + cellGender.textContent = person.sex === 'm' ? 'Male' : 'Female'; - cellBorn.textContent = person.born; + const cellBorn = document.createElement('td'); - const cellDied = document.createElement('td'); + cellBorn.textContent = person.born; - cellDied.textContent = person.died; + const cellDied = document.createElement('td'); - const cellAge = document.createElement('td'); + cellDied.textContent = person.died; - cellAge.textContent = person.died - person.born; + const cellAge = document.createElement('td'); - const cellCentury = document.createElement('td'); + cellAge.textContent = person.died - person.born; - cellCentury.textContent = Math.ceil(person.died / 100); + const cellCentury = document.createElement('td'); - row.append(cellName, cellGender, cellBorn, cellDied, cellAge, cellCentury); + cellCentury.textContent = Math.ceil(person.died / 100); - table.append(row); -}); + row.append(cellName, cellGender, cellBorn, cellDied, cellAge, cellCentury); + tableBody.append(row); + }); +}