From 57533abd88bba8e32d023451de2911dd45724e82 Mon Sep 17 00:00:00 2001 From: Paul Sink Date: Thu, 8 Oct 2020 09:09:40 -0400 Subject: [PATCH 1/2] completed fundamentals 1 --- fundamentals.js | 1 + 1 file changed, 1 insertion(+) diff --git a/fundamentals.js b/fundamentals.js index 61adf3e..2d99490 100644 --- a/fundamentals.js +++ b/fundamentals.js @@ -3,6 +3,7 @@ // #1: Create an array of strings called `foods` that contains three foods. // Type your solution immediately below this line: +var foods = ['apple', 'sandwich', 'cheese']; // #2: Access the last item in the array and assign to a variable called `last`. // Type your solution immediately below this line: From 0bc8244fad2e91ec717f3b3f2ae81caed818b5d3 Mon Sep 17 00:00:00 2001 From: Paul Sink Date: Thu, 8 Oct 2020 09:27:28 -0400 Subject: [PATCH 2/2] completed both sections of checkpoint --- fundamentals.js | 16 ++++++++++++---- oojs.js | 12 +++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/fundamentals.js b/fundamentals.js index 2d99490..6e2cca8 100644 --- a/fundamentals.js +++ b/fundamentals.js @@ -8,24 +8,32 @@ var foods = ['apple', 'sandwich', '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[foods.length - 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 (let i = 0; i < foods.length; i++) { + favoriteFoods.push(foods[i]); +} // #5: Create an object literal called `instructor` that contains three key-value pairs. // Type your solution immediately below this line: - +var instructor = { + subject: "math", + school: "GA", + inPerson: false, +} // #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..ae9126e 100644 --- a/oojs.js +++ b/oojs.js @@ -6,7 +6,15 @@ // - 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); + } +} @@ -15,7 +23,9 @@ // Type your solution immediately below this line: +var myPlaylist = new Playlist ('myPlaylist'); +myPlaylist.addSong('Superstition'); // NOTE: THE CODE BELOW IS FOR TESTING PURPOSES. DO NOT REMOVE OR ALTER.