forked from ga-wdi-exercises/checkpoint-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoojs.js
More file actions
31 lines (26 loc) · 1.06 KB
/
oojs.js
File metadata and controls
31 lines (26 loc) · 1.06 KB
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
// 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 (newSong) {
this.songs.push(newSong)
}
}
// #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('Christmas Playlist')
myPlaylist.addSong('White Christmas')
// NOTE: THE CODE BELOW IS FOR TESTING PURPOSES. DO NOT REMOVE OR ALTER.
if(typeof Playlist !== 'undefined') {
module.exports = {
Playlist
}
}