From f41ba782276ac164aac55eb5d8e1f2f8ba4d42f3 Mon Sep 17 00:00:00 2001 From: Joe Allen Date: Fri, 6 Dec 2019 09:17:36 -0600 Subject: [PATCH 1/3] fundamentals --- fundamentals.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fundamentals.js b/fundamentals.js index e3877d9..b8c2cc4 100644 --- a/fundamentals.js +++ b/fundamentals.js @@ -2,26 +2,34 @@ // #1: Create an array of strings called `foods` that contains three foods. // Type your solution immediately below this line: - +var foods = ["apple", "steak", "potato"]; // #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]; // #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 (let 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 = { + name: "Dave", + age: 23, + sex: "m" +} @@ -29,3 +37,5 @@ // 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"] = false; + From 78c4f013d4b46bf2c1afc12a4db4c76bd2d8d2ce Mon Sep 17 00:00:00 2001 From: Joe Allen Date: Fri, 6 Dec 2019 09:22:25 -0600 Subject: [PATCH 2/3] hof --- hof.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hof.js b/hof.js index c8d3baa..9413698 100644 --- a/hof.js +++ b/hof.js @@ -20,10 +20,15 @@ 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(person => person.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(person => { + if (person.knownLanguages > 1) { + return person; + } +}); \ No newline at end of file From de55701cbe68e24968488a4e7e929fd876377230 Mon Sep 17 00:00:00 2001 From: Joe Allen Date: Fri, 6 Dec 2019 09:26:19 -0600 Subject: [PATCH 3/3] oojs --- oojs.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/oojs.js b/oojs.js index 4c836c7..7c18b85 100644 --- a/oojs.js +++ b/oojs.js @@ -5,7 +5,15 @@ // - 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(song) { + this.songs.push(song); + } +} @@ -14,7 +22,8 @@ // 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("Joe's Faves"); +myPlaylist.addSong("Break it Down Again");