i have declare a subclass named CD for more challenge but when i want to call a shuffle method from my class i get this thing in the console :
[Function: shuffle]
this is my code :
class Media {
constructor(title){
this._title = title;
this._isCheckedOut = false
this._ratings = []
}
get title(){
return this._title
}
get isCheckedOut() {
return this._isCheckedOut
}
set isChekedOut (newisCheckedOut) {
return this._isCheckedOut = newisCheckedOut
}
get ratings() {
return this._ratings
}
toggleCheckedOutStatus (){
this._isCheckedOut = !this._isCheckedOut
}
get average () {
return this.getAverageRating()
}
getAverageRating (){
let ratingsSum = this._ratings.reduce(( currentSum, rating) => currentSum + rating)
return ratingsSum / this._ratings.length
}
addRating(rate) {
this._ratings.push(rate)
}
}
class CD extends Media {
constructor(title) {
super(title)
this._songs = []
}
get songs() {
return this._songs
}
addSongs(song) {
this._songs.push(song)
}
get shuffle() {
return this.shuffle()
}
shuffle() {
songNum = Math.floor(Math.random() * this._songs.length)
return this._songs[songNum]
}
}
const rap = new CD ('Rap')
rap.addSongs('3arbouch')
rap.addSongs('7oumani')
rap.addSongs('Inti 7ayala')
rap.addSongs('LOSE YOURSELF')
console.log(rap.shuffle)