Advertisement
didkoslawow

Untitled

Feb 23rd, 2023
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function songs(playlist) {
  2.   class Song {
  3.     constructor(typeList, songName, songDuration) {
  4.       this.type = typeList;
  5.       this.name = songName;
  6.       this.duration = songDuration;
  7.     }
  8.   }
  9.  
  10.   const songsCount = playlist.shift();
  11.   let printType = playlist.splice(playlist.length - 1, 1)[0];
  12.  
  13.   for (const songInfo of playlist) {
  14.     const [typeList, songName, songDuration] = songInfo.split('_');
  15.     const song = new Song(typeList, songName, songDuration);
  16.  
  17.     if (printType === 'all') {
  18.       console.log(song.name);
  19.     } else {
  20.       if (song.type === printType) {
  21.         console.log(song.name);
  22.       }
  23.     }
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement