diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/Week-1/Homework/mandatory/1-writers.js b/Week-1/Homework/mandatory/1-writers.js index 82acf6f..91b6a33 100644 --- a/Week-1/Homework/mandatory/1-writers.js +++ b/Week-1/Homework/mandatory/1-writers.js @@ -14,31 +14,42 @@ let writers = [ lastName: "Woolf", occupation: "writer", age: 59, - alive: false + alive: false, }, { firstName: "Zadie", lastName: "Smith", occupation: "writer", age: 41, - alive: true + alive: true, }, { firstName: "Jane", lastName: "Austen", occupation: "writer", age: 41, - alive: false + alive: false, }, { firstName: "bell", lastName: "hooks", occupation: "writer", age: 64, - alive: true - } + alive: true, + }, ]; +writers.forEach(function (writer) { + console.log( + `"Hi, my name is ${writer.firstName} ${writer.lastName}. I am ${writer.age} years old, and work as a ${writer.occupation}."` + ); +}); /* If you want an extra challenge, only `console.log()` the writers that are alive. */ + +writers.forEach(function (writer) { + if (writer.alive === true) { + console.log(`The writer ${writer.firstName} ${writer.lastName} is alive`); + } +}); diff --git a/Week-1/Homework/mandatory/2-water-bottle.js b/Week-1/Homework/mandatory/2-water-bottle.js index 981d7e3..c6dcbd5 100644 --- a/Week-1/Homework/mandatory/2-water-bottle.js +++ b/Week-1/Homework/mandatory/2-water-bottle.js @@ -10,15 +10,18 @@ We made a start on this for you here: let bottle = { volume: 0, - fill: function() { + fill: function () { // calling this function should make you bottles volume = 100; + bottle.volume = 100; }, - drink: function() { + drink: function () { // calling this function should decrease your bottles volume by 10; + bottle.volume = 10; }, - empty: function() { + empty: function () { // this function should return true if your bottles volume = 0 - } + bottle.volume = 0; + }, }; /* diff --git a/Week-1/Homework/mandatory/3-groceries.js b/Week-1/Homework/mandatory/3-groceries.js index 2b34cdb..3aac9cf 100644 --- a/Week-1/Homework/mandatory/3-groceries.js +++ b/Week-1/Homework/mandatory/3-groceries.js @@ -10,3 +10,9 @@ let groceryList = { item2: "", item3: "" }; + +for (let grocery in groceryList) { + groceriesToBuy.push(groceryList[grocery]); +} + +console.log(groceriesToBuy); \ No newline at end of file diff --git a/Week-1/Homework/mandatory/4-codewars.md b/Week-1/Homework/mandatory/4-codewars.md index bac0d95..3f17b36 100644 --- a/Week-1/Homework/mandatory/4-codewars.md +++ b/Week-1/Homework/mandatory/4-codewars.md @@ -15,3 +15,6 @@ Exercises: - [Crash Override](https://www.codewars.com/kata/crash-override/train/javascript) - [Job Matching #1](https://www.codewars.com/kata/56c22c5ae8b139416c00175d/train/javascript) - [Split the Bill](https://www.codewars.com/kata/5641275f07335295f10000d0/train/javascript) + + +Codewar solutions link: https://www.codewars.com/users/edksam/completed_solutions \ No newline at end of file diff --git a/Week-1/InClass/B-objects-get-set/exercise-1.js b/Week-1/InClass/B-objects-get-set/exercise-1.js index 6591384..1717d5b 100644 --- a/Week-1/InClass/B-objects-get-set/exercise-1.js +++ b/Week-1/InClass/B-objects-get-set/exercise-1.js @@ -3,16 +3,14 @@ */ let kitten = { - ageMonths: 3, - isFemale: true, - furColour: "brown" + ageMonths: 3, + isFemale: true, + furColour: "brown", }; // YOUR CODE GOES BELOW HERE +console.log(kitten.ageMonths); +console.log(kitten.isFemale); +console.log(kitten.furColour); - - - - - -// YOUR CODE GOES ABOVE HERE \ No newline at end of file +// YOUR CODE GOES ABOVE HERE diff --git a/Week-2/Homework/mandatory/2-exercises/exercises.js b/Week-2/Homework/mandatory/2-exercises/exercises.js index 174c5db..9b1e3c2 100644 --- a/Week-2/Homework/mandatory/2-exercises/exercises.js +++ b/Week-2/Homework/mandatory/2-exercises/exercises.js @@ -15,6 +15,14 @@ */ function exerciseOne(arrayOfPeople) { let content = document.querySelector("#content"); + arrayOfPeople.forEach((person) => { + h1 = document.createElement("h1"); + h2 = document.createElement("h2"); + h1.textContent = person.name; + h2.textContent = person.job; + content.appendChild(h1); + content.appendChild(h2); + }); } /** @@ -25,12 +33,23 @@ function exerciseOne(arrayOfPeople) { * */ function exerciseTwo(shopping) { - //Write your code in here + let contentDiv = document.getElementById("content"); + // create Element of unordered list inside div + let list = document.createElement("ul"); + contentDiv.appendChild(list); + + shopping.forEach((shoppingItem) => { + let li = document.createElement("li"); + li.textContent = shoppingItem; + // let arrItem = document.createTextNode(shoppingItem); + // li.appendChild(arrItem); + list.appendChild(li); + }); } /** I'd like to display my three favorite books inside a nice webpage! - + const books = [ { title: "The Design of Everyday Things", @@ -48,17 +67,53 @@ 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