From 956e9e8ce8a5e9721064d5e12def8af7f8e55bbe Mon Sep 17 00:00:00 2001 From: ngumina17 Date: Fri, 6 Dec 2019 09:59:50 -0600 Subject: [PATCH] js checkpoint --- fundamentals.js | 39 ++++++++++++++++++++++++--------------- hof.js | 15 +++++++++++---- oojs.js | 10 ++++++++-- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/fundamentals.js b/fundamentals.js index e3877d9..6c923d6 100644 --- a/fundamentals.js +++ b/fundamentals.js @@ -1,31 +1,40 @@ -// NOTE: Make sure to use the `var` keyword for ALL variable declarations. +// // NOTE: Make sure to use the `var` keyword for ALL variable declarations. -// #1: Create an array of strings called `foods` that contains three foods. -// Type your solution immediately below this line: +// // #1: Create an array of strings called `foods` that contains three foods. +// // Type your solution immediately below this line: +var foods = ['cheese', 'cereal', 'yogurt'] -// #2: Access the last item in the array and assign to a variable called `last`. -// Type your solution immediately below this line: +// // #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() +// // #3: Create an empty array called `favoriteFoods`. +// // Type your solution immediately below this line: +var favoriteFoods = [''] -// #3: Create an empty array called `favoriteFoods`. -// Type your solution immediately below this line: +// // #4: Create a `for` loop that adds each string in `foods` to `favoriteFoods`. +// // Type your solution immediately below this line: +var favoriteFoods = foods.length; +for (var i= 0; i < foods.length; i++) { + console.log(favoriteFoods[i]); +} -// #4: Create a `for` loop that adds each string in `foods` to `favoriteFoods`. -// Type your solution immediately below this line: - - - -// #5: Create an object literal called `instructor` that contains three key-value pairs. -// Type your solution immediately below this line: - +// // #5: Create an object literal called `instructor` that contains three key-value pairs. +// // Type your solution immediately below this line: +var instructor = { + head: 'Ali', + instructorAssistant: 'Kenny', + newInstructorAssistant: 'Nathaniel' +}; // #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 = 'Dan', diff --git a/hof.js b/hof.js index c8d3baa..911f720 100644 --- a/hof.js +++ b/hof.js @@ -20,10 +20,17 @@ 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( d => peopleNames); + 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: +// // #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(knownLanguages => { + return knownLanguages > 1; + console.log(polyglotPeople) +}) + diff --git a/oojs.js b/oojs.js index 4c836c7..57fc94b 100644 --- a/oojs.js +++ b/oojs.js @@ -6,7 +6,13 @@ // - an `addSong` method that adds a song (string) to the `songs` array // Type your solution immediately below this line: - +class Playlist { + constructor(title, songs, addSong) { + this.title = title + this.songs = songs + this.addSong = + } +} @@ -14,7 +20,7 @@ // 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('')