From 6b86c912e08b30922abcee2af40082ebf934089b Mon Sep 17 00:00:00 2001 From: Osman Date: Wed, 22 Jul 2020 22:15:12 +0100 Subject: [PATCH] first commit --- Week-1/Homework/mandatory/1-writers.js | 6 +- Week-1/Homework/mandatory/2-water-bottle.js | 13 +- Week-1/Homework/mandatory/3-groceries.js | 10 +- Week-1/Homework/projects/1-recipes.js | 13 +- Week-1/Homework/projects/2-reading-list.js | 53 +++++++- .../A-objects-intro/exercise-part-0.js | 19 ++- .../A-objects-intro/exercise-part-1.js | 17 +++ .../A-objects-intro/exercise-part-2.js | 19 +-- .../InClass/B-objects-get-set/exercise-1.js | 4 +- .../InClass/B-objects-get-set/exercise-2.js | 12 +- .../InClass/B-objects-get-set/exercise-3.js | 4 +- .../InClass/B-objects-get-set/exercise-4.js | 4 +- .../C-more-complex-objects/exercise-1.js | 4 +- .../C-more-complex-objects/exercise-2.js | 3 + .../C-more-complex-objects/exercise-3.js | 10 +- Week-1/InClass/D-methods/exercise-1.js | 15 ++- Week-1/InClass/D-methods/exercise-2.js | 4 +- Week-1/InClass/D-methods/exercise-3.js | 9 +- Week-1/InClass/D-methods/exercise-4.js | 6 +- Week-1/InClass/D-methods/exercise-5.js | 5 +- .../InClass/E-arrays-of-objects/exercise-1.js | 14 +- .../InClass/E-arrays-of-objects/exercise-2.js | 22 +++- .../InClass/E-arrays-of-objects/exercise-3.js | 120 +++++++++++------- .../InClass/F-object-keys/exercise-part-0.js | 4 +- .../InClass/F-object-keys/exercise-part-1.js | 18 +-- .../InClass/F-object-keys/exercise-part-2.js | 7 +- 26 files changed, 299 insertions(+), 116 deletions(-) diff --git a/Week-1/Homework/mandatory/1-writers.js b/Week-1/Homework/mandatory/1-writers.js index 82acf6f..13cd020 100644 --- a/Week-1/Homework/mandatory/1-writers.js +++ b/Week-1/Homework/mandatory/1-writers.js @@ -38,7 +38,11 @@ let writers = [ alive: true } ]; - +for(let key in writers){ + if(writers[key].alive === true ){ + console.log(`Hi, my name is ${writers[key].firstName} ${writers[key].lastName}. I am ${writers[key].age} years old, and work as a ${writers[key].occupation}`); + } +} /* If you want an extra challenge, only `console.log()` the writers that are alive. */ diff --git a/Week-1/Homework/mandatory/2-water-bottle.js b/Week-1/Homework/mandatory/2-water-bottle.js index 981d7e3..87c2f8b 100644 --- a/Week-1/Homework/mandatory/2-water-bottle.js +++ b/Week-1/Homework/mandatory/2-water-bottle.js @@ -11,14 +11,23 @@ We made a start on this for you here: let bottle = { volume: 0, fill: function() { - // calling this function should make you bottles volume = 100; + calling this function should make you bottles volume = 100; + this.volume = 100; + return this.volume; + }, drink: function() { - // calling this function should decrease your bottles volume by 10; + calling this function should decrease your bottles volume by 10; + this.volume -= 10; + return this.volume; }, empty: function() { // this function should return true if your bottles volume = 0 + if(this.volume === 0){ + return true; + } } + }; /* diff --git a/Week-1/Homework/mandatory/3-groceries.js b/Week-1/Homework/mandatory/3-groceries.js index 2b34cdb..6a48ac4 100644 --- a/Week-1/Homework/mandatory/3-groceries.js +++ b/Week-1/Homework/mandatory/3-groceries.js @@ -6,7 +6,11 @@ let groceriesToBuy = []; let groceryList = { - item1: "", - item2: "", - item3: "" + item1: "Potatoes", + item2: "Orange Juice", + item3: "Rice" }; +for(let key in groceryList){ + groceriesToBuy.push(groceryList[key]); +} +console.log(groceriesToBuy); diff --git a/Week-1/Homework/projects/1-recipes.js b/Week-1/Homework/projects/1-recipes.js index 3ada67c..cbacdaa 100644 --- a/Week-1/Homework/projects/1-recipes.js +++ b/Week-1/Homework/projects/1-recipes.js @@ -22,4 +22,15 @@ cocoa **/ -let recipes = {}; +let recipes = { + title: 'Mole', + servings: 2, + ingredients: ['cinnamon', 'cumin', 'cocoa'], +}; +console.log(recipes.title); +console.log(`Serves: ${recipes.servings}`); +console.log(`Ingredients:`); +console.log(recipes.ingredients[0]); +console.log(recipes.ingredients[1]); +console.log(recipes.ingredients[2]); + diff --git a/Week-1/Homework/projects/2-reading-list.js b/Week-1/Homework/projects/2-reading-list.js index 939e3e2..94fc89b 100644 --- a/Week-1/Homework/projects/2-reading-list.js +++ b/Week-1/Homework/projects/2-reading-list.js @@ -25,4 +25,55 @@ If you read it, log a string like 'You already read "The Hobbit" by J.R.R. Tolki **/ -let books = []; +let books = [ + { + title: 'To Kill a Mockingbird', + author: 'Harper Lee', + alreadyRead: true, + }, + { + title: 'The Great Gatsby', + author: 'F. Scott Fitzgerald', + alreadyRead: false, + }, + { + title: 'One Hundred Years of Solitude', + author: 'Gabriel García Márquez', + alreadyRead: true, + }, + { + title: 'The Lord of the Rings', + author: 'J.R.R', + alreadyRead: true, + }, + { + title: 'Invisible Man', + author: 'Ralph Ellison', + alreadyRead: false, + }, + { + title: 'Don Quixote', + author: 'Miguel de Cervantes', + alreadyRead: false, + }, + { + title: 'Beloved', + author: 'Toni Morrison', + alreadyRead: true, + }, + { + title: 'The Hobbit', + author: 'J.R.R', + alreadyRead: false, + }, +]; +// for(let value in books){ +// console.log(`${books[value].title} by ${books[value].author}.`); +// } +for(let key in books){ + if(books[key].alreadyRead === true){ + console.log(`You already read ${books[key].title} by ${books[key].author}.`) + }else{ + console.log(`You still need to read ${books[key].title} by ${books[key].author}.`) + } +} diff --git a/Week-1/InClass/A-objects-intro/exercise-part-0.js b/Week-1/InClass/A-objects-intro/exercise-part-0.js index 433d27c..a43761d 100644 --- a/Week-1/InClass/A-objects-intro/exercise-part-0.js +++ b/Week-1/InClass/A-objects-intro/exercise-part-0.js @@ -4,4 +4,21 @@ Describe your own laptop as a JavaScript object Try to think of as many properties as you can! -*/ \ No newline at end of file +*/ +let laptop = { + brand: 'Lenovo', + screenSize: 14, + memory: '4-GB', + processor: 'Intel Core i5', + disk: 320, + operatingSystem: 'Linux-Ubuntu', + touchScreen: false, +}; +console.log(laptop); +console.log(laptop.brand); +console.log(laptop.screenSize); +console.log(laptop.memory); +console.log(laptop.processor); +console.log(laptop.disk); +console.log(laptop.operatingSystem); +console.log(laptop.touchScreen); diff --git a/Week-1/InClass/A-objects-intro/exercise-part-1.js b/Week-1/InClass/A-objects-intro/exercise-part-1.js index 49e1ed9..5a3daa2 100644 --- a/Week-1/InClass/A-objects-intro/exercise-part-1.js +++ b/Week-1/InClass/A-objects-intro/exercise-part-1.js @@ -6,4 +6,21 @@ can describe with a JavaScript object Assign each of them to a separate variable */ +let car = { + make: 'Volkswagon', + model: 'Golf', + year: 2006, + engineSize: '1.9 cc', + color: 'Green', + fuelType: 'Diesel', + automaticGearbox: false, +}; +console.log(car); +console.log(car.make); +console.log(car.model); +console.log(car.year); +console.log(car.engineSize); +console.log(car.color); +console.log(car.fuelType); +console.log(car.automaticGearbox); diff --git a/Week-1/InClass/A-objects-intro/exercise-part-2.js b/Week-1/InClass/A-objects-intro/exercise-part-2.js index 4e01403..5378725 100644 --- a/Week-1/InClass/A-objects-intro/exercise-part-2.js +++ b/Week-1/InClass/A-objects-intro/exercise-part-2.js @@ -5,17 +5,18 @@ The objects below have some syntax issues - try and fix them all! */ let kitten = { - fur colour: "orange", - age "23" + furcolour: "orange", + age: "23" }; -let laptop = - brand: "Lenovo" - ram "5GB" -} +let laptop = { + brand: "Lenovo", + ram: "5GB", +}; let phone = { - operating system "iOS", + 'operating system': "iOS", hasStylus: true, - megapixels 12 - "batteryLife": "24 hours" \ No newline at end of file + megapixels: 12, + batteryLife: "24 hours", +}; \ 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..b716f91 100644 --- a/Week-1/InClass/B-objects-get-set/exercise-1.js +++ b/Week-1/InClass/B-objects-get-set/exercise-1.js @@ -10,7 +10,9 @@ let kitten = { // YOUR CODE GOES BELOW HERE - +console.log(kitten.ageMonths); +console.log(kitten.isFemale); +console.log(kitten.furColour); diff --git a/Week-1/InClass/B-objects-get-set/exercise-2.js b/Week-1/InClass/B-objects-get-set/exercise-2.js index c8b5e7b..961aa33 100644 --- a/Week-1/InClass/B-objects-get-set/exercise-2.js +++ b/Week-1/InClass/B-objects-get-set/exercise-2.js @@ -5,14 +5,14 @@ */ let phone = { - brand: 'iPhone, - model 'iPhone X' + brand: 'iPhone', + model: 'iPhone X', launchYear: 2017, - is Unlocked: true -; + isUnlocked: true +}; -let phoneBrand = phone.bbrand; -let phoneLaunchYear = phone[launchYear]; +let phoneBrand = phone.brand; +let phoneLaunchYear = phone.launchYear; // DO NOT MODIFY BELOW THIS LINE diff --git a/Week-1/InClass/B-objects-get-set/exercise-3.js b/Week-1/InClass/B-objects-get-set/exercise-3.js index f775c9a..0050599 100644 --- a/Week-1/InClass/B-objects-get-set/exercise-3.js +++ b/Week-1/InClass/B-objects-get-set/exercise-3.js @@ -3,7 +3,9 @@ */ // WRITE CODE BELOW THIS - +let kitten = { + name: 'Gilbert' +}; // WRITE CODE ABOVE THIS console.log(kitten.name); diff --git a/Week-1/InClass/B-objects-get-set/exercise-4.js b/Week-1/InClass/B-objects-get-set/exercise-4.js index 763347e..4ea8c8d 100644 --- a/Week-1/InClass/B-objects-get-set/exercise-4.js +++ b/Week-1/InClass/B-objects-get-set/exercise-4.js @@ -8,9 +8,9 @@ let dog = { }; // WRITE CODE BELOW THIS LINE +dog.name = 'Rex'; - - +dog.wantsToPlay = true; // WRITE CODE ABOVE THIS LINE diff --git a/Week-1/InClass/C-more-complex-objects/exercise-1.js b/Week-1/InClass/C-more-complex-objects/exercise-1.js index 8ae3e82..dffcca5 100644 --- a/Week-1/InClass/C-more-complex-objects/exercise-1.js +++ b/Week-1/InClass/C-more-complex-objects/exercise-1.js @@ -20,9 +20,11 @@ let house = { */ // - change the address of "house" to '51 Berkley Road' +house.address = '51 Berkley Road'; // - change the previous owners of "house" to ["Brian M.", "Fiona S."] +house.previousOwners = ["Brian M.", "Fiona S."]; // - change the last name of the current owner of "house" to "Montgomery" - +house.currentOwner.lastName ='Montgomery'; /* DO NOT EDIT ANYTHING BELOW THIS LINE diff --git a/Week-1/InClass/C-more-complex-objects/exercise-2.js b/Week-1/InClass/C-more-complex-objects/exercise-2.js index 7ea0200..5fd1990 100644 --- a/Week-1/InClass/C-more-complex-objects/exercise-2.js +++ b/Week-1/InClass/C-more-complex-objects/exercise-2.js @@ -26,8 +26,11 @@ let newCurrentOwner = { */ // - assign the value of the variable 'newCurrentOwner' as the value to the house's "currentOwner" +house.currentOwner = newCurrentOwner; // - from the list of previous owners, replace only "John A." with "Stephen B." +house.previousOwners[1] = 'Stephen B'; // - give the house a new property called 'isForSale' with the value 'false' +house.isForSale = false; diff --git a/Week-1/InClass/C-more-complex-objects/exercise-3.js b/Week-1/InClass/C-more-complex-objects/exercise-3.js index 4bfbfd3..a9cafee 100644 --- a/Week-1/InClass/C-more-complex-objects/exercise-3.js +++ b/Week-1/InClass/C-more-complex-objects/exercise-3.js @@ -32,17 +32,21 @@ let parkAvenueHouse = { // returns the full name (first name + last name) of the owner of the house function getOwnerFullName(house) { - + return `${house.currentOwner.firstName} ${house.currentOwner.lastName}`; } // returns an array of the owners' email addresses of the two houses function getEmailAddresses(house1, house2) { - + return `${house1.currentOwner.email} ${house2.currentOwner.email}`; } // returns the address for the cheapest house out of the two function getCheapestAddress(house1, house2) { - + if(house1.price < house2.price){ + return house1.address; + }else{ + return house2.address; + } } diff --git a/Week-1/InClass/D-methods/exercise-1.js b/Week-1/InClass/D-methods/exercise-1.js index 8de0f8c..f3f3c71 100644 --- a/Week-1/InClass/D-methods/exercise-1.js +++ b/Week-1/InClass/D-methods/exercise-1.js @@ -3,16 +3,17 @@ A person named Alice is defined below. Add a method "greet" so this person can say hello. */ - let person = { - name: "Alice", - age: 25 + name: "Alice", + age: 25, +}; +person.greet = function greeting(){ + return 'Hello everybody'; }; - - /* DO NOT EDIT ANYTHING BELOW THIS LINE */ - -console.log(`Expected result: Hello everybody. Actual result: ${person.greet()}`); \ No newline at end of file +console.log( + `Expected result: Hello everybody. Actual result: ${person.greet()}` +); diff --git a/Week-1/InClass/D-methods/exercise-2.js b/Week-1/InClass/D-methods/exercise-2.js index 8e993fc..86c1724 100644 --- a/Week-1/InClass/D-methods/exercise-2.js +++ b/Week-1/InClass/D-methods/exercise-2.js @@ -9,7 +9,9 @@ let person = { name: "Alice", age: 25 }; - +person.sayName = function sayingOwnName(){ + return `My name is ${this.name}`; +}; /* DO NOT EDIT ANYTHING BELOW THIS LINE diff --git a/Week-1/InClass/D-methods/exercise-3.js b/Week-1/InClass/D-methods/exercise-3.js index be23748..65cd5f3 100644 --- a/Week-1/InClass/D-methods/exercise-3.js +++ b/Week-1/InClass/D-methods/exercise-3.js @@ -8,11 +8,12 @@ let person = { name: "Alice", age: 25, currentAddress: "Glasgow", - changeAddress: (newAddress) { - currentAddress = newAddress; + changeAddress: function (newAddress) { + return this.currentAddress = newAddress; + }, - celebrateBirthday: function { - that.age = that.age + 1; + celebrateBirthday: function(age) { + return this.age = this.age + 1; } }; diff --git a/Week-1/InClass/D-methods/exercise-4.js b/Week-1/InClass/D-methods/exercise-4.js index d89214a..3524808 100644 --- a/Week-1/InClass/D-methods/exercise-4.js +++ b/Week-1/InClass/D-methods/exercise-4.js @@ -8,12 +8,14 @@ let person = { name: "Alice", friends: ["John", "Nina"] }; - +person.makeFriend = function(newFriends){ + return this.friends.push(newFriends); +}; /* DO NOT EDIT ANYTHING BELOW THIS LINE */ person.makeFriend("Bob"); - +person.makeFriend("Alice"); console.log(`Expected result: 'John,Nina,Bob'. Actual result: ${person.friends}`); \ No newline at end of file diff --git a/Week-1/InClass/D-methods/exercise-5.js b/Week-1/InClass/D-methods/exercise-5.js index dcd198c..5cf9a90 100644 --- a/Week-1/InClass/D-methods/exercise-5.js +++ b/Week-1/InClass/D-methods/exercise-5.js @@ -17,10 +17,11 @@ let coffeeMachine = { }, insertedAmount: 0, insertMoney: function (amount) { - + amount = this.insertedAmount; + return amount; }, getCoffee: function (coffee) { - + } }; diff --git a/Week-1/InClass/E-arrays-of-objects/exercise-1.js b/Week-1/InClass/E-arrays-of-objects/exercise-1.js index 8d39a81..694f744 100644 --- a/Week-1/InClass/E-arrays-of-objects/exercise-1.js +++ b/Week-1/InClass/E-arrays-of-objects/exercise-1.js @@ -25,11 +25,15 @@ WRITE YOUR CODE BELOW */ -var persons = // Complete here - -var personNames = // Complete here - -var personsYoungerThan28YearsOld = // Complete here +var persons = [person1, person2, person3]; // Complete here +function takeNames(person){ + return person.name; +} +let personNames = persons.map(takeNames); // Complete here +function youngerThan28(person){ + return person.age < 28; +} +var personsYoungerThan28YearsOld = persons.filter(youngerThan28); // Complete here /* diff --git a/Week-1/InClass/E-arrays-of-objects/exercise-2.js b/Week-1/InClass/E-arrays-of-objects/exercise-2.js index c2259dd..ae3f7c9 100644 --- a/Week-1/InClass/E-arrays-of-objects/exercise-2.js +++ b/Week-1/InClass/E-arrays-of-objects/exercise-2.js @@ -39,12 +39,26 @@ DO NOT EDIT ANYTHING ABOVE THIS LINE WRITE YOUR CODE BELOW */ +function checkWithin500Kms(destination) { + return destination.distanceKms <= 500; +} +function getDestinationNames(destination) { + return destination.destinationName; +} -let destinationNamesWithin500Kms = // Complete here +let destinationNamesWithin500Kms = travelDestinations.filter(checkWithin500Kms).map(getDestinationNames); // Complete here +function getFerry(destination) { + return destination.transportations.includes("ferry"); +} +function reachAbleTrain(destination) { + return destination.transportations.includes("train"); +} +let destinationNameReachableByFerry = travelDestinations.filter(getFerry).map(getDestinationNames); // Complete here + function moreThan300kn(destination) { + return destination.distanceKms >= 300; + } -let destinationNameReachableByFerry = // Complete here - -let destinationNamesMoreThan300KmsAwayByTrain = // Complete here (PRINT THE RESULT IN THE CONSOLE USING FOREACH) +let destinationNamesMoreThan300KmsAwayByTrain = travelDestinations.filter(moreThan300kn).filter(reachAbleTrain).map(getDestinationNames);// Complete here (PRINT THE RESULT IN THE CONSOLE USING FOREACH) /* diff --git a/Week-1/InClass/E-arrays-of-objects/exercise-3.js b/Week-1/InClass/E-arrays-of-objects/exercise-3.js index a1ec691..bd8da42 100644 --- a/Week-1/InClass/E-arrays-of-objects/exercise-3.js +++ b/Week-1/InClass/E-arrays-of-objects/exercise-3.js @@ -15,36 +15,36 @@ and returns the number of restaurants in this area. */ let restaurant1 = { - name: "Paesano", - totalSeats: 10, - numberOfCustomers: 8, - address: { - city: "Glasgow", - area: "center" - }, - menu: ["pizza", "calzone", "salad"] + name: "Paesano", + totalSeats: 10, + numberOfCustomers: 8, + address: { + city: "Glasgow", + area: "center", + }, + menu: ["pizza", "calzone", "salad"], }; let restaurant2 = { - name: "Ubiquitous Chip", - totalSeats: 20, - numberOfCustomers: 10, - address: { - city: "Glasgow", - area: "west" - }, - menu: ["salad", "chocolate cake", "roast lamb"] + name: "Ubiquitous Chip", + totalSeats: 20, + numberOfCustomers: 10, + address: { + city: "Glasgow", + area: "west", + }, + menu: ["salad", "chocolate cake", "roast lamb"], }; let restaurant3 = { - name: "Monkeyz", - totalSeats: 15, - numberOfCustomers: 8, - address: { - city: "Glasgow", - area: "center" - }, - menu: ["stew", "chocolate cake", "panini"] + name: "Monkeyz", + totalSeats: 15, + numberOfCustomers: 8, + address: { + city: "Glasgow", + area: "center", + }, + menu: ["stew", "chocolate cake", "panini"], }; let restaurants = [restaurant1, restaurant2, restaurant3]; @@ -54,32 +54,60 @@ DO NOT EDIT ANYTHING ABOVE THIS LINE WRITE YOUR CODE BELOW */ - let restaurantFinderApplication = { - applicationName: "Restaurant Finder", - applicationVersion: "1.0", - restaurants: restaurants, - findAvailableRestaurants: function (numberOfPeople) { - // Complete here - }, - findRestaurantServingDish: function (dishName) { - // Complete here - }, - countNumberOfRestaurantsInArea: function (area) { - // Complete here - } + applicationName: "Restaurant Finder", + applicationVersion: "1.0", + restaurants: restaurants, + findAvailableRestaurants: function (numberOfPeople) { + // Complete here + let nameOfRestaurants = ""; + restaurants.forEach((restaurant) => { + if ( + numberOfPeople <= + restaurant.totalSeats - restaurant.numberOfCustomers + ) { + nameOfRestaurants += restaurant.name + ","; + } + }); + return nameOfRestaurants; + }, + findRestaurantServingDish: function (dishName) { + // Complete here + restaurants.filter((restaurant) => { + let newAee = []; + newAee.push((restaurant) => { + return menu.includes(dishName).map(restaurant.name); + + }); + + }); + }, + countNumberOfRestaurantsInArea: function (area) { + // Complete here + }, }; - /* DO NOT EDIT ANYTHING BELOW THIS LINE */ -let restaurantsAvailableFor5People = restaurantFinderApplication.findAvailableRestaurants(5); -console.log(`Find available restaurants for 5 people: Expected result: Ubiquitous Chip,Monkeyz, actual result: ${restaurantsAvailableFor5People}`); - -let restaurantsServingSalad = restaurantFinderApplication.findRestaurantServingDish("salad"); -console.log(`Find restaurants serving salad: Expected result: Paesano,Ubiquitous Chip, actual result: ${restaurantsServingSalad}`); - -let numberOfRestaurantsInCityCentre = restaurantFinderApplication.countNumberOfRestaurantsInArea("center"); -console.log(`Number of restaurants in city centre: Expected result: 2, actual result: ${numberOfRestaurantsInCityCentre}`); +let restaurantsAvailableFor5People = restaurantFinderApplication.findAvailableRestaurants( + 5 +); +console.log( + `Find available restaurants for 5 people: Expected result: Ubiquitous Chip,Monkeyz, actual result: ${restaurantsAvailableFor5People}` +); + +let restaurantsServingSalad = restaurantFinderApplication.findRestaurantServingDish( + "salad" +); +console.log( + `Find restaurants serving salad: Expected result: Paesano,Ubiquitous Chip, actual result: ${restaurantsServingSalad}` +); + +let numberOfRestaurantsInCityCentre = restaurantFinderApplication.countNumberOfRestaurantsInArea( + "center" +); +console.log( + `Number of restaurants in city centre: Expected result: 2, actual result: ${numberOfRestaurantsInCityCentre}` +); diff --git a/Week-1/InClass/F-object-keys/exercise-part-0.js b/Week-1/InClass/F-object-keys/exercise-part-0.js index d9b1085..2588f93 100644 --- a/Week-1/InClass/F-object-keys/exercise-part-0.js +++ b/Week-1/InClass/F-object-keys/exercise-part-0.js @@ -20,8 +20,8 @@ let highScores = { // ONLY EDIT BELOW HERE -let capitalCitiesKeys = ; -let highScoresKeys; +let capitalCitiesKeys = Object.keys(capitalCities); +let highScoresKeys = Object.keys(highScores); // ONLY EDIT ABOVE HERE diff --git a/Week-1/InClass/F-object-keys/exercise-part-1.js b/Week-1/InClass/F-object-keys/exercise-part-1.js index b8d4be7..4bae4a3 100644 --- a/Week-1/InClass/F-object-keys/exercise-part-1.js +++ b/Week-1/InClass/F-object-keys/exercise-part-1.js @@ -7,17 +7,19 @@ You're going to have to used what we learned at the start of this lesson, and so */ let mentorsAges = { - james: 29, - JOSH: 35, - JAMIE: 25, - Mozafar: 30 + james: 29, + JOSH: 35, + JAMIE: 25, + Mozafar: 30, }; // ONLY EDIT BELOW THIS LINE - -let mentorsNames = ; - -let mentorsNamedUppercased = ; +function allCapitalLetters(names) { + return names.toUpperCase(); +} +let mentorsNames = Object.keys(mentorsAges); +console.log(mentorsNames); +let mentorsNamedUppercased = mentorsNames.map(allCapitalLetters); // ONLY EDIT ABOVE THIS LINE diff --git a/Week-1/InClass/F-object-keys/exercise-part-2.js b/Week-1/InClass/F-object-keys/exercise-part-2.js index 6b6a1bb..2840745 100644 --- a/Week-1/InClass/F-object-keys/exercise-part-2.js +++ b/Week-1/InClass/F-object-keys/exercise-part-2.js @@ -35,14 +35,15 @@ let storeBranches = { // # 1 // prints [ 'glasgow', 'edinburgh' ] -console.log() +console.log(Object.keys(storeBranches)); // # 2 + // prints [ 'manager', 'assistant', 'interns' ] -console.log() +console.log(Object.keys(storeBranches.glasgow)); // # 3 // prints [ 'head_intern', 'intern' ] -console.log() +console.log(Object.keys(storeBranches.edinburgh.interns)) // ONLY EDIT ABOVE THIS LINE