diff --git a/fundamentals.js b/fundamentals.js index 61adf3e..257aab7 100644 --- a/fundamentals.js +++ b/fundamentals.js @@ -2,25 +2,34 @@ // #1: Create an array of strings called `foods` that contains three foods. // Type your solution immediately below this line: +var foods = ['pizza', 'pasta', 'garlic bread']; // #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 = { + name: 'Dhruv', + lastName: 'Didi', + workXP: 'Google' +} @@ -28,3 +37,4 @@ // 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/oojs.js b/oojs.js index 4c836c7..430ea45 100644 --- a/oojs.js +++ b/oojs.js @@ -5,7 +5,15 @@ // - a `songs` property that is an empty array not determined by input (not passed into the constructor) // - 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(string) { + this.songs.push(string); + } +} @@ -13,7 +21,8 @@ // #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('2009 Jams'); +myPlaylist.addSong("Thick Country Skin of my Yellow Country Teeth");