-
Create a constructor function called
Artist
. TheArtist
constructor function should have 2 properties:- a
name
property, which can be accepted as an argument of the constructor function and set on the object - and a
songs
property that defaults to an empty array
- a
-
Create a constructor function called
Song
. TheSong
constructor function should have 3 properties:- a
title
property, which can be accepted as an argument of the constructor function and set on the object- the
title
should be a string containing the title of a song
- the
- an
artist
property, which can be accepted as an argument of the constructor function and set on the object- the
artist
should be an instance of anArtist
object
- the
- a
playCount
property that defaults to 0 (NOTE:playCount
is not passed in as a parameter on the constructor function)
- a
-
Inside the
Song
constructor function, find the currentsong
'sartist
property, and push the currentsong
object into theartist
'ssongs
array property. This way, thesong
has a reference to theartist
, and theartist
has an array that contains all of theirsongs
.- Think about how to refer to the current
Song
. What keyword does an instance use to refer to itself?
- Think about how to refer to the current
BONUS:
- Write a
play()
function for aSong
that incrementsplayCount
.
All content is licensed under a CCBYNCSA 4.0 license. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].