From e147a6c9b651a08a23d963884f7af09b2925d0e3 Mon Sep 17 00:00:00 2001 From: Danny Gleason Date: Fri, 6 Dec 2019 11:02:44 -0500 Subject: [PATCH] test complete --- fundamentals.js | 14 ++++++++++++++ hof.js | 8 ++++++++ oojs.js | 14 +++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/fundamentals.js b/fundamentals.js index e3877d9..209297d 100644 --- a/fundamentals.js +++ b/fundamentals.js @@ -3,29 +3,43 @@ // #1: Create an array of strings called `foods` that contains three foods. // Type your solution immediately below this line: +var foods = ["apple", "banana", "cheese"] // #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.pop() +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 (let index = 0; index < foods.length; index++) { + favoriteFoods.push(foods[index]) +} // #5: Create an object literal called `instructor` that contains three key-value pairs. // Type your solution immediately below this line: +var instructor = { + name: "kelly", + age: 35, + specialty: "OOP", +}; // #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..d5238af 100644 --- a/hof.js +++ b/hof.js @@ -22,8 +22,16 @@ var people = [ // Type your solution immediately below this line: +var peopleNames = people.map(item => item.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 polyglotObj = people.filter(item => item.knownLanguages >= 2) +var polyglotPeople = polyglotObj.map(item => item.name) +//how to do this in one step? + diff --git a/oojs.js b/oojs.js index 4c836c7..21bf494 100644 --- a/oojs.js +++ b/oojs.js @@ -7,6 +7,17 @@ // Type your solution immediately below this line: +class Playlist{ + constructor(title){ + this.title = title + this.songs = []; + } + + addSong(){ + this.songs.push(this.title) + return this.songs + } +} @@ -15,7 +26,8 @@ // Type your solution immediately below this line: - +var myPlaylist = new Playlist("Stairway to Heaven"); +myPlaylist.addSong() // NOTE: THE CODE BELOW IS FOR TESTING PURPOSES. DO NOT REMOVE OR ALTER.