Shuffle Error ? Build a Library


I think i F up the program , would you help me out here

Code :

       class CD extends Media {
  constructor(title,artist,trackCount) {
    this._artist = artist
    this._trackCount = [] 
  get artist() {
    return this._artist
  get trackCount() {
		return this._trackCount
  addTrack(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'])

Error :

Yo, if you could please help me out as quick as possible thanks!


shuffle doesn’t return anything, so it returns undefined.

so by calling console.log() when you call shuffle, you log this returned result to the console. Just get rid of console.log when calling shuffle to not log returned result


Done,then what am i supposed to do next?


i would first fix your indent before moving on. The indent looks like a mess.


Just like my life :cry:


well, indent is fixable so then your life should be fixable as well, making the same analogy.


ayeee JK man,loving life


impossible, programmers do not have enjoyable life.

spoiler: just kidding


Nice, what am i supposed to do know