From a6a1354006f4b2cef303e880accf20b419e36ee0 Mon Sep 17 00:00:00 2001 From: saintaubins Date: Fri, 6 Dec 2019 11:03:05 -0500 Subject: [PATCH] done --- fundamentals.js | 17 +++++++++++++---- hof.js | 14 ++++++++++++++ oojs.js | 17 +++++++++++++++-- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/fundamentals.js b/fundamentals.js index e3877d9..768cb51 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 = ['apple', 'banana', 'grapes']; // #2: Access the last item in the array and assign to a variable called `last`. // Type your solution immediately below this line: - +foods[2] = '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 (var i = 0; i < foods.length; i++){ + favoriteFoods[i] = foods[i]; +}; // #5: Create an object literal called `instructor` that contains three key-value pairs. // Type your solution immediately below this line: - + var instructor = { + firstName: 'John', + lastName: 'Doe', + age: 45 + }; // #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; \ No newline at end of file diff --git a/hof.js b/hof.js index c8d3baa..a4e6f92 100644 --- a/hof.js +++ b/hof.js @@ -21,9 +21,23 @@ var people = [ // called `peopleNames`. // Type your solution immediately below this line: +var peopleNames = people.map(getNames); +function getNames(evt){ + return evt.name; +} // #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(getPolyglot); + +function getPolyglot(evt) { + if(people.knownLanguages.value > 1) { + return people.knownLanguages.value; + } + +} \ No newline at end of file diff --git a/oojs.js b/oojs.js index 4c836c7..31f0dc3 100644 --- a/oojs.js +++ b/oojs.js @@ -6,7 +6,20 @@ // - 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(evt) { + + songs = push(evt); + + } +} @@ -15,8 +28,8 @@ // Type your solution immediately below this line: - - +var myPlaylist = new Playlist("myTitle"); +myPlaylist.addSong('mySong'); // NOTE: THE CODE BELOW IS FOR TESTING PURPOSES. DO NOT REMOVE OR ALTER. if(typeof Playlist !== 'undefined') {