Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/test.yml-template
Original file line number Diff line number Diff line change
@@ -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
31 changes: 28 additions & 3 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,32 @@ const people = [
},
];

// eslint-disable-next-line no-console
console.log(people); // you can remove it
const table = document.querySelector('table');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The task requires finding the table with class dashboard. This line uses a generic tag selector which may not target the correct element. Use a class selector such as document.querySelector('table.dashboard') or document.querySelector('.dashboard').


// write your code here
for (const person of people) {
const row = document.createElement('tr');
const cell1 = document.createElement('td');
const cell2 = document.createElement('td');
const cell3 = document.createElement('td');
const cell4 = document.createElement('td');
const cell5 = document.createElement('td');
const cell6 = document.createElement('td');

const age = person.died - person.born;
const century = Math.ceil(person.died / 100);

if (person.sex === 'm') {
cell2.textContent = 'Male';
} else {
cell2.textContent = 'Female';
}

cell1.textContent = person.name;
cell3.textContent = person.born;
cell4.textContent = person.died;
cell5.textContent = age;
cell6.textContent = century;

row.append(cell1, cell2, cell3, cell4, cell5, cell6);
table.append(row);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Appending rows directly to table will throw if the selector above returns null. Add a guard like if (!table) return; or select the correct element first to avoid runtime errors when table is not found.

}
Loading