forked from ga-wdi-exercises/checkpoint-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oojs.js
42 lines (32 loc) · 1.14 KB
/
oojs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// NOTE: Make sure to use the `var` keyword for ALL variable declarations
// #1: Define a `Playlist` class with the following properties:
// - a `title` property that is a string determined by some input (passed into the constructor)
// - 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{
songs = [];
constructor(title)
{
this.title = title;
/*this.songs = songs;*/
}
addSong(song)
{
this.songs = song;
return this.songs;
}
}
// #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("title1");
var myArr = [];
myArr[0] = "Song1";
myPlaylist.addSong(myArr[0]);
// NOTE: THE CODE BELOW IS FOR TESTING PURPOSES. DO NOT REMOVE OR ALTER.
if(typeof Playlist !== 'undefined') {
module.exports = {
Playlist
}
}