{"id":41375234,"url":"https://github.com/thinkful-ed/jsdom-assignment-solution","last_synced_at":"2026-01-23T10:04:37.521Z","repository":{"id":53124259,"uuid":"353752260","full_name":"Thinkful-Ed/jsdom-assignment-solution","owner":"Thinkful-Ed","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-05T19:34:41.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":9,"default_branch":"main","last_synced_at":"2023-05-09T21:10:35.539Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Thinkful-Ed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-01T15:55:15.000Z","updated_at":"2023-01-09T22:13:31.000Z","dependencies_parsed_at":"2022-09-01T10:01:04.278Z","dependency_job_id":null,"html_url":"https://github.com/Thinkful-Ed/jsdom-assignment-solution","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/Thinkful-Ed/jsdom-assignment-solution","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinkful-Ed%2Fjsdom-assignment-solution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinkful-Ed%2Fjsdom-assignment-solution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinkful-Ed%2Fjsdom-assignment-solution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinkful-Ed%2Fjsdom-assignment-solution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thinkful-Ed","download_url":"https://codeload.github.com/Thinkful-Ed/jsdom-assignment-solution/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thinkful-Ed%2Fjsdom-assignment-solution/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28687415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-23T10:02:10.764Z","updated_at":"2026-01-23T10:04:37.503Z","avatar_url":"https://github.com/Thinkful-Ed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\n\n# JSDOM: Assignment\n\nYou are building a contact book. The list of contacts and relevant details are stored in an array named `contacts`. You wish to create a few helper functions to display the contacts, filter by city and make a few modifications.\n\n## Existing Files\n\n| file path               | description                                                                                                                                                                           |\n| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `index.html`            | It contains placeholder elements for the list of contacts to be rendered. It also contains a form for filtering the list of contacts. _You should not edit the HTML file in any way_. |\n| `index.css`             | A few basic styles. This challenge does not focus on style. You may ignore this file.                                                                                                 |\n| `index.js`              | You need to write your JavaScript code in this file. This is the only file that you need to edit. You will find the `contacts` array declared in this file.                           |\n| `test/solution.test.js` | The tests your code will run against. You do not need to edit this file.                                                                                                              |\n\n## Tasks\n\nThe contacts array contain contacts in the following format:\n\n```javascript\n    {\n      id: 39,\n      name: \"Arwen Undómiel\",\n      email: \"arwen@imladris.com\",\n      picture: \"https://via.placeholder.com/150/FE0F0B/FFFFFF?Text=AU\",\n      address: {\n        street: \"Main Street\",\n        suite: \"Suite 17\",\n        city: \"Imladris\",\n        zipcode: \"90566-7771\",\n        geo: {\n          lat: \"-43.9509\",\n          lng: \"-34.4618\",\n        },\n      },\n      phone: \"010-692-6593 x09125\",\n      website: \"arwen.com\",\n      company: {\n        name: \"Eriador Services\",\n        catchPhrase: \"Proactive didactic contingency\",\n        bs: \"synergize scalable supply-chains\",\n      },\n    },\n```\n\nWrite the following functions in the `index.js` file.\n\n#### `renderContact()`\n\nThis function accepts a contact object in the format described above.\nCreate and return the HTML to render a single contact. The HTML for a single contact should look like this:\n\n```html\n\u003cdiv class=\"card\" data-id=\"39\"\u003e\n  \u003cbutton class=\"deleteBtn\" title=\"Delete this contact\"\u003eX\u003c/button\u003e\n  \u003cdiv class=\"avatar\"\u003e\n    \u003cdiv class=\"circle\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"circle\"\u003e\u003c/div\u003e\n    \u003cimg src=\"https://via.placeholder.com/150/FE0F0B/FFFFFF?Text=AU\" /\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"info\"\u003e\n    \u003cspan class=\"name big\"\u003eArwen Undómiel\u003c/span\u003e\n    \u003cspan class=\"email small\"\u003earwen@imladris.com\u003c/span\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"details\"\u003e\n    \u003cdiv class=\"phone\"\u003e010-692-6593 x09125\u003c/div\u003e\n    \u003cdiv class=\"website\"\u003earwen.com\u003c/div\u003e\n  \u003c/div\u003e\n\n  \u003cdiv class=\"additional\"\u003e\n    \u003cdiv class=\"address\"\u003e\n      \u003cdiv class=\"suite\"\u003eSuite 17\u003c/div\u003e\n      \u003cdiv class=\"street\"\u003eMain Street\u003c/div\u003e\n      \u003cdiv class=\"city\"\u003eImladris, 90566-7771\u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"company\"\u003e\n      \u003cdiv class=\"label\"\u003eWorks at\u003c/div\u003e\n      \u003cdiv class=\"company-name\"\u003eEriador Services\u003c/div\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n_The tests are looking for these specific elements and class names to be used. Be sure to check your spelling properly._\n\n#### `loadCities()`\n\nAccepts an array of contacts.\nThe load cities function finds all unique cities in the contact list and inserts a set of options in the select element with the id `filterOptions`. The default option should remain in place.\n\nAfter populating the `filterOptions` select it should look like this:\n\n```html\n\u003cselect name=\"filterOptions\" id=\"filterOptions\"\u003e\n  \u003coption value=\"0\"\u003e-- Select a city --\u003c/option\u003e\n  \u003coption value=\"New York\"\u003eNew York\u003c/option\u003e\n  \u003coption value=\"Kinsasha\"\u003eKinsasha\u003c/option\u003e\n\u003c/select\u003e\n```\n\n#### `render()`\n\nThis method accepts an array of contacts.\nRender the array of contacts and insert them into the DOM.\n\nAdditionally, call the `loadCities()` function to ensure that the list of cities in the filter is updated.\n\nThe contacts should be rendered in the `section` with id \"contacts\". If there are no contacts in the list simply leave the section empty.\n\n#### `filterByCity()`\n\nAccepts a string representing the name of a city. Filter the list of contacts by contacts that live in the given city. Create a new array for the filtered contact. DO NOT MODIFY THE ORIGINAL CONTACTS ARRAY. Return the filtered contacts.\n\n#### `filterHandler()`\n\nThis function attaches a change event listener to the `filterOptions` select. On change get the value of the select that was selected. If the value is \"0\" then call `render()` with the full list of contacts. Otherwise, call `filterByCity()` with the city that the user selected, then call render with the filtered list produced.\n\n#### `deleteContact()`\n\nAccepts an id representing the id of a contact in the contact list. Remove the contact from the contact list with the given id. If the id does not exist then no contacts are deleted.\n\n#### `deleteButtonHandler()`\n\nAdd a `click` event handler to the `deleteBtn` elements.\nWhen clicked, get the id of the card that was clicked from the\ncorresponding `data-id` then call `deleteContact()` and re-render\nthe list.\n\n#### `main()`\n\nThis is the starting point of the code. Call the necessary functions to add event listeners then render the contacts.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkful-ed%2Fjsdom-assignment-solution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkful-ed%2Fjsdom-assignment-solution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkful-ed%2Fjsdom-assignment-solution/lists"}