From b290a69ed211fc7d765920edd026bd3775394db3 Mon Sep 17 00:00:00 2001 From: Amanul Islam Date: Sat, 5 Sep 2020 17:30:50 +0100 Subject: [PATCH 1/3] Week 2 complete --- .../mandatory/2-exercises/exercises.js | 55 ++++++++++++++----- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/Week-2/Homework/mandatory/2-exercises/exercises.js b/Week-2/Homework/mandatory/2-exercises/exercises.js index 174c5db..1dff1e8 100644 --- a/Week-2/Homework/mandatory/2-exercises/exercises.js +++ b/Week-2/Homework/mandatory/2-exercises/exercises.js @@ -15,8 +15,16 @@ */ function exerciseOne(arrayOfPeople) { let content = document.querySelector("#content"); + for (var i = 0; i < arrayOfPeople.length; i++) { + // names and jobs + let nameEl = document.createElement("h1"); + let jobEl = document.createElement("h2"); + content.appendChild(nameEl); + content.appendChild(jobEl); + nameEl.innerHTML = arrayOfPeople[i].name; + jobEl.innerHTML = arrayOfPeople[i].job; + } } - /** * * Create a list of shopping items. You should use an unordered list. @@ -26,11 +34,15 @@ function exerciseOne(arrayOfPeople) { */ function exerciseTwo(shopping) { //Write your code in here + let content = document.querySelector("#content"); + for (var i = 0; i < shopping.length; i++) { + let shoppingList = document.createElement("ul"); + content.appendChild(shoppingList); + shoppingList.innerHTML = shopping[i]; + } } - /** I'd like to display my three favorite books inside a nice webpage! - const books = [ { title: "The Design of Everyday Things", @@ -48,19 +60,42 @@ function exerciseTwo(shopping) { alreadyRead: true } ]; - Iterate through the array of books. - For each book, create a

element with the book title and author and append it to the page. - Use a