From 61fd53b595cec0157ebfec5a8a9a0b1524709f75 Mon Sep 17 00:00:00 2001 From: Phil Morales Date: Fri, 6 Dec 2019 11:02:01 -0500 Subject: [PATCH] submission --- fundamentals.js | 19 ++++++++++++++----- hof.js | 8 +++++++- index.html | 2 +- oojs.js | 18 +++++++++++++++--- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/fundamentals.js b/fundamentals.js index e3877d9..1c090ef 100644 --- a/fundamentals.js +++ b/fundamentals.js @@ -3,29 +3,38 @@ // #1: Create an array of strings called `foods` that contains three foods. // Type your solution immediately below this line: - +var foods = ["apples", "oranges", "grapes"]; // #2: Access the last item in the array and assign to a variable called `last`. // Type your solution immediately below this line: +var last = foods[2]; - +console.log(last); // #3: Create an empty array called `favoriteFoods`. // Type your solution immediately below this line: - - +var favoriteFoods = []; // #4: Create a `for` loop that adds each string in `foods` to `favoriteFoods`. // Type your solution immediately below this line: +for (i = 0; i < foods.length; i++){ + favoriteFoods.push(foods[i]); + console.log(favoriteFoods); +} // #5: Create an object literal called `instructor` that contains three key-value pairs. // Type your solution immediately below this line: - +var instructor = { + firstName: 'Jack', + lastName: 'Ryan', + movie: 'CIA' +}; // #6: Add a `has-office-hours` (spelled exactly) property to `instructor` by accessing // it (do not change the original object you typed above) and assigning it // a boolean value. // Type your solution immediately below this line: +instructor['has-office-hours'] = 'true' diff --git a/hof.js b/hof.js index c8d3baa..2150cbf 100644 --- a/hof.js +++ b/hof.js @@ -20,10 +20,16 @@ var people = [ // person in the `people` array. Assign the returned array to a variable // called `peopleNames`. // Type your solution immediately below this line: - +var peopleNames = people.map(x => [x.name]); +console.log(peopleNames); // #2: Use the `filter` array method to create a new, filtered array containing only // persons from the `people` array who know multiple languages. Assign the returned array // to a variable called `polyglotPeople`. // Type your solution immediately below this line: + +var polyglotPeople = people.filter(function (el){ + return el.knownLanguages > 1; +}) +//console.log(polyglotPeople); \ No newline at end of file diff --git a/index.html b/index.html index cd1f465..b1cbd86 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - + diff --git a/oojs.js b/oojs.js index 4c836c7..5220e57 100644 --- a/oojs.js +++ b/oojs.js @@ -5,7 +5,19 @@ // - a `songs` property that is an empty array not determined by input (not passed into the constructor) // - an `addSong` method that adds a song (string) to the `songs` array // Type your solution immediately below this line: +class Playlist { + constructor(title) { + this.title = title; + this.songs = [] +} + +addSong(string) { +var addSong = this.songs.push[string]; +console.log(addSong); + +} +} @@ -13,9 +25,9 @@ // #2: Create an instance of the Playlist class and set it to a variable called `myPlaylist` // Call the instance's `addSong` method to add a song to the instance's `songs` array // Type your solution immediately below this line: - - - +var myPlaylist = new Playlist('jingle bells') +myPlaylist.addSong(); +console.log(myPlaylist); // NOTE: THE CODE BELOW IS FOR TESTING PURPOSES. DO NOT REMOVE OR ALTER.