Hi! Can anyone help me with this, I’m just a beginner in JS, and I want to try to do the task of making a shuffle method, so I watched a tutorial and searched online on how to do this, but unfortunately I didn’t get it, Can you please me to understand this… Thank you!
class CD extends Media {
constructor(artist, title, songs) {
super(title);
this._artist = artist;
this._songs = ;
}
get artist() {
return this._artist;
}
get songs() {
return this._songs;
}
const shuffle(songs) = {
mySongs = [‘Blessings’, ‘In Christ Alone’, ‘Still’, ‘The Prayer’];
function shuffled(mySongs) {
let shuffledArray = ;
let usedIndexes = ;
let i = 0;
while (i < thi._songs.length) {
let randomNumber = Math.floor(Math.random() * this._songs.length);
if (!usedIndexes.inlcudes(randomNumber)) {
shuffledArray.push(this._songs[randomNumber]);
usedIndexes.push(randomNumber);
i++;
}
}
return shuffledArray;
}
}