diff --git a/README.md b/README.md index a4241d05f..6a1f010e4 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_generate_table_DOM/) + - [DEMO LINK](https://HiljSV.github.io/js_task_generate_table_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; diff --git a/src/scripts/main.js b/src/scripts/main.js index 7d4a5db04..129eff464 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -354,7 +354,24 @@ const people = [ }, ]; -// eslint-disable-next-line no-console -console.log(people); // you can remove it +const table = document.querySelector('.dashboard'); +const tableBody = table.tBodies[0]; -// write your code here +const getGender = (sex) => (sex === 'm' ? 'Male' : 'Female'); + +people.forEach((person) => { + const row = tableBody.insertRow(); + + const values = [ + person.name, + getGender(person.sex), + person.born, + person.died, + person.died - person.born, + Math.ceil(person.died / 100), + ]; + + values.forEach((value) => { + row.insertCell().textContent = value; + }); +});