forked from ga-wdi-exercises/checkpoint-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoojs.js
36 lines (26 loc) · 1.04 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
// 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{
constructor(title){
this.title = title
this.songs = []
}
addSong(song){
this.songs.push(song)
}
}
// #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("BoneyM")
myPlaylist.addSong("daddy! daddy cool!")
// NOTE: THE CODE BELOW IS FOR TESTING PURPOSES. DO NOT REMOVE OR ALTER.
if(typeof Playlist !== 'undefined') {
module.exports = {
Playlist
}
}