diff --git a/debugging/demo/demo1/demo1.js b/debugging/demo/demo1/demo1.js index 0d8e695..2cbce39 100644 --- a/debugging/demo/demo1/demo1.js +++ b/debugging/demo/demo1/demo1.js @@ -1,35 +1,42 @@ -const tomatoes = 'tomatoes'; -const chocolate= 'chocolate'yummy'; -const yogurt = 'yogurt'; +const tomatoes = "tomatoes"; +const chocolate = "chocolate yummy"; +const yogurt = "yogurt"; const rice = "rice"; -const fridge =[{ item: tomatoes, quantity: 5}, - { item: chocolate, quantity: 1}, - { item: yogurt, quantity: 5}]; +const fridge = [ + { item: tomatoes, quantity: 5 }, + { item: chocolate, quantity: 1 }, + { item: yogurt, quantity: 5 }, +]; -const wantedList = [{ item: tomatoes, quantity: 4}, - { item: chocolate, quantity: 10}, - { item: yogurt, quantity: 2}] +const wantedList = [ + { item: tomatoes, quantity: 4 }, + { item: chocolate, quantity: 10 }, + { item: yogurt, quantity: 2 }, +]; const shoppingList = (fridge, wantedList) => { - return wantedList.map(groceryWantedList => { - let groceryFridge = fridge.find( gf => gf.item === groceryWantedList.item); - if (groceryFridge===null){ + return wantedList + .map((groceryWantedList) => { + let groceryFridge = fridge.find( + (gf) => gf.item === groceryWantedList.item + ); + if (groceryFridge === null) { return groceryWantedList; } else { - if (groceryFridge.quantity < groceryWantedList.quantity){ + if (groceryFridge.quantity < groceryWantedList.quantity) { return { - item: groceryWantedList.item, - quantity: groceryWantedList.quantity - groceryFridge.quantity + item: groceryWantedList.item, + quantity: groceryWantedList.quantity - groceryFridge.quantity, }; - } - else{ - return null; + } else { + return null; + } } - } - }).filter(item => item !== null); + }) + .filter((item) => item !== null); }; -shoppingList (fridge, wantedList).forEach( (item) => { - console.log (`${item.item}: ${item.quantity}`); - }) \ No newline at end of file +shoppingList(fridge, wantedList).forEach((item) => { + console.log(`${item.item}: ${item.quantity}`); +}); diff --git a/debugging/demo/demo2/index.html b/debugging/demo/demo2/index.html index 8cc1a42..2207d59 100644 --- a/debugging/demo/demo2/index.html +++ b/debugging/demo/demo2/index.html @@ -1,6 +1,5 @@
- Javascript Demo Exercise 2 + + diff --git a/debugging/demo/demo2/script.js b/debugging/demo/demo2/script.js index 1c7bec9..4321eb9 100644 --- a/debugging/demo/demo2/script.js +++ b/debugging/demo/demo2/script.js @@ -1,43 +1,48 @@ -document.addEventListener("DOMContentLoaded", ( ) => { - var data = [ - { - text: 'Overshadowing #UNGA is the big question: Will Obama and Rouhani meet?', - href: 'https://twitter.com/cnnbrk/status/382528782738800641' - }, - { - text: "Marine's family hopes visiting Iranian president will help free their son", - href: 'https://twitter.com/cnnbrk/status/382519683053649920' - }, - { - text: 'Obama addresses United Nations.', - href: 'https://twitter.com/cnnbrk/status/382507500903202817' - }, - { - text: '', - href: 'https://twitter.com/CNNMoney/status/382497891723804672' - }, - { - text: "If you're seeing this as a button, congratulations!", - href: 'http://twitter.com' - } - ]; - for (var i = 0; i