I think i F up the program , would you help me out here
Code :
class CD extends Media {
constructor(title,artist,trackCount) {
super(title)
this._artist = artist
this._trackCount = []
}
get artist() {
return this._artist
}
get trackCount() {
return this._trackCount
}
addTrack(trac) {
this._trackCount.push(trac)
}
shuffle() {
const a = this._trackCount.length
for (let i = 0; i < a ; i++) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
}
}
const test = new CD('INVALID' , 'INVALID' , 2)
console.log(' ')
test.addTrack(['Cant Hold US' , 'Cukup Tau'])
console.log(test.trackCount)
console.log(test.shuffle())
Error :
UNDEFINED
Yo, if you could please help me out as quick as possible thanks!