Easy
This question is a daily question and will count towards your daily streak.
You're developing a music app, and users can create playlists by chaining together actions like adding songs, removing songs, and shuffling the playlist. The following class handles these operations, but the shuffle functionality is incomplete. Which missing line will correctly implement the shuffle behavior?
1class Playlist {2 constructor() {3 this.songs = [];4 }56 addSong(song) {7 this.songs.push(song);8 return this; // Enable chaining9 }1011 removeSong(song) {12 this.songs = this.songs.filter(s => s !== song);13 return this; // Enable chaining14 }1516 shuffle() {17 this.songs = /* Missing Line Here */;18 return this; // Enable chaining19 }2021 print() {22 console.log(this.songs);23 return this;24 }25}2627// Example Usage:28let myPlaylist = new Playlist();29myPlaylist30 .addSong('Song A')31 .addSong('Song B')32 .addSong('Song C')33 .shuffle()34 .print();