From ce7c148916bf50a6ac9fb0249dc43e995588245f Mon Sep 17 00:00:00 2001 From: Austin Benckendorf Date: Thu, 8 Oct 2020 09:02:57 -0500 Subject: [PATCH] changed --- fundamentals.js | 24 ++++++++++++++++++++---- oojs.js | 13 +++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/fundamentals.js b/fundamentals.js index 61adf3e..74df20c 100644 --- a/fundamentals.js +++ b/fundamentals.js @@ -2,29 +2,45 @@ // #1: Create an array of strings called `foods` that contains three foods. // Type your solution immediately below this line: - +var foods = ["Pizza", "Beef", "Cereal"] +console.log(foods) // #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] +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: +foods.forEach(function pushFav(food) {favoriteFoods.push(food)}) +console.log(favoriteFoods) + +// for (i = 0; i < foods.length; i++) { +// favoriteFoods.push([i]) +// console.log(favoriteFoods) +// } // what's wrong ? // #5: Create an object literal called `instructor` that contains three key-value pairs. // Type your solution immediately below this line: - +var instructor = { + firstName : "Rob", + lastName : "Tyne", + age : "55" +}; // #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 // how to change this? + +console.log(instructor) \ No newline at end of file diff --git a/oojs.js b/oojs.js index 4c836c7..4f77f31 100644 --- a/oojs.js +++ b/oojs.js @@ -7,6 +7,15 @@ // Type your solution immediately below this line: +class Playlist { + songs = [] + constructor(title) { + this.title = title; + } + addSong(song) { + this.songs.push(song); +}; +} @@ -14,7 +23,11 @@ // Call the instance's `addSong` method to add a song to the instance's `songs` array // Type your solution immediately below this line: +myPlaylist = new Playlist("myPlaylist"); +myPlaylist.addSong("Lay it all on me") +console.log(myPlaylist); +console.log(myPlaylist.songs);