From 3d9fbff215aa02a783c2bc8a9f97740798545667 Mon Sep 17 00:00:00 2001 From: Alex Overstreet Date: Thu, 8 Oct 2020 10:02:31 -0400 Subject: [PATCH] complete --- fundamentals.js | 19 +++++++++++++------ oojs.js | 14 +++++++++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/fundamentals.js b/fundamentals.js index 61adf3e..161d7e3 100644 --- a/fundamentals.js +++ b/fundamentals.js @@ -2,29 +2,36 @@ // #1: Create an array of strings called `foods` that contains three foods. // Type your solution immediately below this line: - +var foods = ['Pizza', 'Shrimp', 'Steak'] // #2: Access the last item in the array and assign to a variable called `last`. // Type your solution immediately below this line: - - +var last = '' +var last =foods[foods.lenghth-1] // #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.push(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', + latName: 'Doe', + subject: 'Software' + } // #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/oojs.js b/oojs.js index 4c836c7..2e6e52d 100644 --- a/oojs.js +++ b/oojs.js @@ -6,15 +6,23 @@ // - an `addSong` method that adds a song (string) to the `songs` array // Type your solution immediately below this line: - +class Playlist { + constructor(title = '', song){ + this.title = title + this.song = [] + } + addSong(title){ + this.song.push(title) + } +} // #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('mySong') +addsong(mySong);