diff --git a/fundamentals.js b/fundamentals.js index 61adf3e..424c4c5 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 = ["strawberry", "banana","apple"]; // #2: Access the last item in the array and assign to a variable called `last`. // Type your solution immediately below this line: - - +var arr = []; +var last = arr.slice(-1)[0]; // #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 ( i=0; i <= foods.length; i++){ + foods[i].join(favoriteFoods); +} // #5: Create an object literal called `instructor` that contains three key-value pairs. // Type your solution immediately below this line: - +var instructor = { + firstName: "Bob", + lastName: "Smith", + age: 100 +}; // #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..54188cd 100644 --- a/oojs.js +++ b/oojs.js @@ -6,7 +6,14 @@ // - 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 + } +var songs= []; +function addSong(i) { + return songs.push(i); +} @@ -15,7 +22,7 @@ // Type your solution immediately below this line: - +myPlaylist= new Playlist (addSong("hello A")); // NOTE: THE CODE BELOW IS FOR TESTING PURPOSES. DO NOT REMOVE OR ALTER.