¡Te damos la bienvenida a este reto!

1

¡Bienvenido al mundo de JavaScript!

Día 1

2

Variables, funciones y sintaxis básica

3

Tipos de datos

4

Playground - Retorna el tipo

5

Tipos de datos - pt 2

Día 2

6

Operadores

7

Hoisting y coerción

8

Playground - Calcula la propina

9

Alcance de las variables

Día 3

10

Condicionales

11

Playground - Calcula años bisiestos

12

Switch

13

Playground - Obten información de mascotas según su tipo

14

Ciclos

15

Playground - Dibuja un triangulo

Día 4

16

Arrays

17

Playground - Encuentra al michi mas famoso

18

Objetos

19

Playground - Obten el promedio de los estudiantes

Día 5 - Checkpoint

20

Playground - encuentra el palindromo más grande

Día 6

21

Reasignación y redeclaración

22

Modo estricto

Día 7

23

Debugging y manejo de errores

24

Programación funcional

Quiz: Día 7

Día 8

25

Closures

26

Playground - Crea una calculadora con closures

27

Higher order functions

28

Playground - Crea tu propio método map

Día 9

29

ECMAScript

30

TC39

Quiz: Día 9

Día 10 - Checkpoint

31

ES6

32

ES7

33

Playground - Task planner

Día 11

34

Asincronismo

35

Playground - Promesas

36

Manejando el asincronismo

37

Playground - Resuelve el callback hell usando promesas

38

Playground - Resuelve el callback hell usando async/await

Día 12

39

Arrays a profundidad

40

Métodos de arrays: Every, Find y findIndex

41

Playground - Válida el formulario

Día 13

42

Métodos de arrays: Includes, Join y concat

43

Playground - agrupa los productos

44

Métodos de arrays: Flat y FlatMap

45

Playground - Encuentra la ubicación del valor buscado

Día 14

46

Mutable functions

47

Playground - Modifica una lista de compras

48

Métodos de arrays: sort

49

Playground - Ordena los productos

Día 15 - Checkpoint

50

Playground - Sistema de reservaciones de un hotel

Día 16

51

Programación orientada a objetos en JavaScript

52

Objetos literales

53

Playground - Congela el objeto recursivamente

Día 17

54

Prototipos en JavaScript

55

Playground - Modifica el prototype de los arrays

56

Playground - Crea un auto usando clases

Día 18

57

Abstracción en JavaScript

58

Playground - Sistema de carrito de compras

59

Encapsulamiento en JavaScript

60

Playground - Encapsula datos de los usuarios

Día 19

61

Herencia en JavaScript

62

Playground - Jerarquía de animales

63

Polimorfismo en JavaScript

64

Playground - Sistema de pagos

Día 20 - Checkpoint

65

Playground - Agenda de vuelos

Día 21

66

Patrones de diseño

67

Sinlgeton y Factory pattern en JavaScript

68

Playground - Implementa singleton en un chat

Día 22

69

Adapter y Decorator pattern en JavaScript

70

Playground - Personaliza productos de una tienda

71

Builder y Protype pattern en JavaScript

72

Playground - Mejora el código usando builder pattern

Día 23

73

Facade y proxy pattern en JavaScript

74

Playground - Proxy en servicio de mensajería

75

Chain of responsability y Observer pattern en JavaScript

76

Playground - Implementación de Observador en Newsletter

Día 24 - Checkpoint

77

Playground - Crea un task manager con patrones de diseño

Día 25

78

Estructuras de datos en JavaScript

79

Playground - Crea tu propia implementación de un array

80

Hash tables en JavaScript

81

Playground - Implementación de una HashTable para Contactos

Día 26

82

Set en JavaScript

83

Playground - Remueve duplicados de una lista

84

Maps en JavaScript

85

Playground - Crea un organizador de tareas

Día 27

86

Singly Linked List en JavaScript

87

Playground - Agrega métodos a la singly linked list

88

Playground - Implementación de una singly linked list

Día 28

89

Stacks en JavaScript

90

Playground - Crea un stack para una playlist

Día 29

91

Queues en JavaScript

92

Playground - Crea una cola de emails

Día 30

93

¡Lo lograste!

Live Class

94

30 días de JS con Juan DC

95

30 días de JS con Nicobytes

96

30 días de JS con GNDX

97

30 días de JS con LeoCode

98

30 días de JS con Teffcode

99

Sesión: Cierre de los 30 días de JavaScript

No tienes acceso a esta clase

¡Continúa aprendiendo! Únete y comienza a potenciar tu carrera

Playground - Crea un stack para una playlist

90/99

Aportes 21

Preguntas 0

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad?

Hola, les dejo mi solución
.
.
.
.
.
.
.
.
.
.

.
.
.
.

export class Node {
  constructor(value) {
    // Tu código aquí 👈🏻
    this.value = value;
    this.next = null;
  }
}

export class Playlist {
  constructor() {
    // Tu código aquí 👈🏻
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    // Tu código aquí 👈🏻
    const newNode = new Node(song);

    if (!this.top) {
      this.top = newNode;
      this.bottom = newNode;
    } else {
      newNode.next = this.top;
      this.top = newNode;
    }
    this.length++;
  }

  playSong() {
    // Tu código aquí 👈🏻
    if (!this.top) {
      throw new Error("No hay canciones en la playlist")
    }

    const currentSong = this.top.value;
    if (this.top === this.bottom) {
      this.bottom = null;
    }
    this.top = this.top.next;
    this.length--;

    return currentSong;
  }

  getPlaylist() {
    // Tu código aquí 👈🏻
    let currentNode = this.top;
    let currentNodeArray = [];
    for (let i = 0; i < this.length; i++) {
      currentNodeArray.push(currentNode.value)
      currentNode = currentNode.next;
    }
    return currentNodeArray;
  }
}

💚Mi Solución💚

🛡️Escudo Anti-spoilers🛡️

👾Código

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null
    this.bottom = null
    this.length = 0
  }

  addSong(song) {
    const newNode = new Node(song)

    if (this.length == 0) {
      this.top = newNode
      this.bottom = newNode
    } else {
      newNode.next = this.top
      this.top = newNode
    }

    this.length++

    return this
  }

  playSong() {
    if (this.length == 0)
      throw new Error("No hay canciones en la lista")

    const song = this.top.value

    if (this.length != 1) {
      this.top = this.top.next
    } else {
      this.top = null
      this.bottom = null
    }

    this.length--
    return song
  }

  getPlaylist() {
    let playlist = []
    let actualSong = this.top
    while (actualSong != null) {
      playlist.push(actualSong.value)
      actualSong = actualSong.next
    }

    return playlist
  }
}

Hola mi aporte:




















node.js

export class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

exercise.js

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newSong = new Node(song);
    if (this.length === 0) {
      this.top = newSong;
      this.bottom = newSong;
    } else {
      newSong.next = this.top;
      this.top = newSong;
    }

    this.length++;
  }

  playSong() {
    if (this.length === 0) {
      throw new Error("No hay canciones en la playlist");
    }

    const actualSong = this.top.value;
    if (this.top === this.bottom) {
      this.bottom = null;
    }

    this.top = this.top.next;

    this.length--;
    return actualSong;
  }

  getPlaylist() {
    const songs = [];
    let current = this.top;

    while (current) {
      songs.push(current.value);
      current = current.next;
    }

    return songs;
  }
}

Aqui esta mi solución:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

//node.js

export class Node {
  constructor(value) {
    // Tu código aquí 👈🏻
    this.value = value;
    this.next = null;
  }
}

//exercise.js

import { Node } from "./node";

export class Playlist {
  constructor() {
    // Tu código aquí 👈🏻
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    // Tu código aquí 👈🏻
    const newSong = new Node(song);

    if (!this.top) {
      this.top = newSong;
      this.bottom = newSong
    }
    else {
      newSong.next = this.top;
      this.top = newSong;
    }
    this.length++;
  }

  playSong() {
    // Tu código aquí 👈🏻
    if (!this.top) throw new Error('No hay canciones en la lista');

    if (this.top === this.bottom) this.bottom = null;

    const playedSong = this.top;
    this.top = this.top.next;
    this.length--;

    return playedSong.value;
  }

  getPlaylist() {
    // Tu código aquí 👈🏻
    const playList = new Array();

    let currentSong = this.top;
    while (currentSong) {
      playList.push(currentSong.value);
      currentSong = currentSong.next;
    }

    return playList;
  }
}


.
.
.
.
.
.

node.js

export class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

exercise.js

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newSong = new Node(song);
    if (!this.top) {
      this.top = newSong;
      this.bottom = newSong;
    } else {
      newSong.next = this.top;
      this.top = newSong;
    }
    this.length++;
  }

  playSong() {
    if (!this.top) {
      throw new Error("No hay canciones en la lista.");
    }
    if (this.top === this.bottom) {
      this.bottom = null;
    }
    let song = this.top.value;
    this.top = this.top.next;
    this.length--;
    return song;
  }

  getPlaylist() {
    let currentSong = this.top;
    const arrayPlaylist = [];
    while (currentSong) {
      arrayPlaylist.push(currentSong.value);
      currentSong = currentSong.next;
    }
    return arrayPlaylist;
  }
} 

Este si estuvo mas fácil, aunque siempre tiene que ser realizado bajo las condiciones ya programadas, solo por una variable que cambie de nombre no me pasaba, pero en fin mi solución
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

node.js

export class Node {
  constructor(value) {
    // Tu código aquí 👈🏻
    this.value = value;
    this.next = null;
  }
} 

exercise.js

import { Node } from "./node";

export class Playlist {
  constructor() {
    // Tu código aquí 👈🏻
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    // Tu código aquí 👈🏻
    const newSong = new Node(song);
    if (!this.top) {
      this.top = newSong;
      this.bottom = newSong;
    } else {
      newSong.next = this.top;
      this.top = newSong;
    }
    this.length++;
    return this;
  }

  playSong() {
    // Tu código aquí 👈🏻
    if (!this.top)
      throw new Error('No hay caciones en la lista');
    if (this.top === this.bottom)
      this.bottom = null;
    let song = this.top.value;
    this.top = this.top.next;
    this.length--;
    return song;
  }

  getPlaylist() {
    // Tu código aquí 👈🏻
    let lSong = this.top;
    const listSongs = [];
    while (lSong) {
      listSongs.push(lSong.value);
      lSong = lSong.next;
    }
    return listSongs;
  }
}

Solución

class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newSong = new Node(song);

    if (this.length === 0) {
      this.top = newSong;
      this.bottom = newSong;
    } else {
      newSong.next = this.top;
      this.top = newSong;
    }

    this.length++;
    return this;
  }

  playSong() {
    if (this.length === 0) return null;

    const deletedSong = this.top.value;

    if (this.length === 1) {
      this.top = null;
      this.bottom = null;
    } else {
      this.top = this.top.next;
    }

    this.length--;
    console.log(deletedSong);
    return this;
  }

  getPlaylist() {
    let currentNode = this.top;
    const array = [];

    while (currentNode) {
      array.push(currentNode.value);

      currentNode = currentNode.next;
    }

    console.log(array);
    return array;
  }
}

🛡️🛡️Escudo anti-spoilers🛡️🛡️

Mi solución al reto:

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null
    this.bottom = null
    this.length = 0
  }

  addSong(song) {
    let newNode = new Node(song)
    if (this.length === 0) {
      this.top = newNode
      this.bottom = newNode
    } else {
      newNode.next = this.top
      this.top = newNode
    }
    this.length++
    return this
  }

  playSong() {
    if (this.length <= 0) throw new Error("No hay canciones en la lista")
    if (this.top === this.bottom) {
      this.bottom = null;
    }
    let play = this.top.value
    this.top = this.top.next
    this.length--
    return play
  }

  getPlaylist() {
    let playlistArray = []
    let currentNode = this.top
    while (currentNode) {
      playlistArray.push(currentNode.value)
      currentNode = currentNode.next
    }
    return playlistArray
  }
}

Aquí mi solución:
.
.
.
.
.
.
.
.
.
.
.
.
node.js

export class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

exercise.js

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null
    this.bottom = null
    this.length = 0
  }

  addSong(song) {
    const newNode = new Node(song);
    if (this.length === 0) {
      this.top = newNode;
      this.bottom = newNode;
    } else {
      newNode.next = this.top;
      this.top = newNode;
    }

    this.length++;
  }

  playSong() {
    if (!this.top) {
      throw new Error("No hay canciones en la playlist");
    }

    if (this.top === this.bottom) {
      this.bottom = null;
    }

    let ssong = this.top.value;
    this.top = this.top.next;
    this.length--;
    return ssong;
  }

  getPlaylist() {
    let playList = [];
    if (this.top) {
      let currentNode = this.top;
      while (currentNode) {
        playList.push(currentNode.value);
        currentNode = currentNode.next;
      }      
    }
    return playList;    
  }
}

MI APORTE 💪
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
class Node

export class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

class Playlist

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newNode = new Node(song);
    if (this.length === 0) {
      this.top = newNode;
      this.bottom = newNode;
    } else {
      newNode.next = this.top;
      this.top = newNode;
    }
    this.length++;
  }

  playSong() {
    if (!this.top) throw new Error("No hay canciones en la lista");
    if (this.top === this.bottom) {
      this.bottom = null;
    }
    const song = this.top.value;
    this.top = this.top.next;
    this.length--;
    return song;
  }

  getPlaylist() {
    const songs = [];
    let currentNode = this.top;
    for (let i = 0; i < this.length; i++) {
      songs.push(currentNode.value);
      currentNode = currentNode.next;
    }
    return songs;
  }
}

node.js

export class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

exercise.js

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newNode = new Node(song);
    if (this.length === 0) {
      this.top = newNode;
      this.bottom = newNode;
    } else {
      const pointer = this.top;
      this.top = newNode;
      this.top.next = pointer;
    }

    this.length++;
    return this;
  }

  playSong() {
    if (this.length === 0) {
      throw new Error("No hay canciones en la lista");
    }
    if (this.top === this.bottom) {
      this.bottom = null;
    }
    const value = this.top.value;
    this.top = this.top.next;
    this.length--;
    return value;
  }

  getPlaylist() {
    if (this.length === 0) {
      return [];
    }
    const array = [];
    let node = this.top;
    array.push( this.top.value)
    while (node.next) {
      array.push(node.next.value);
      node = node.next;
    }
    return array;
  }
}

Mi solución:
.
.
.
.
.
.
.
.

node.js

export class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

exercise.js

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null
    this.bottom = null
    this.length = 0
  }

  addSong(song) {
    const newSong = new Node(song)
    if (this.length === 0) {
      this.top = newSong
      this.bottom = newSong
    } else {
      newSong.next = this.top
      this.top = newSong
    }
    this.length++
  }

  playSong() {
    if (!this.top) {
      throw new Error("No hay canciones en la playlist")
    }
    const currentSong = this.top
    if (currentSong === this.bottom) {
      this.bottom = null
    }
    this.top = this.top.next
    this.length--
    return currentSong.value
  }

  getPlaylist() {
    let array = []
    let currentSong = this.top
    while (currentSong) {
      array.push(currentSong.value)
      currentSong = currentSong.next
    }
    return array
  }
}

Les comparte mi humilde solucion
.
.
.
.
.
.
.
.
.

.
.
.
.
.

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newSong = new Node(song);
    if (this.length === 0) {
      this.top = newSong;
      this.bottom = newSong;
    } else {
      newSong.next = this.top;
      this.top = newSong;
    }
    this.length++;
  }

  playSong() {
    if (!this.top) {
      throw new Error("No hay canciones en la playlist");
    }
    const current = this.top.value
    if (this.top === this.bottom) {
      this.bottom = null
    }

    this.top = this.top.next
    this.length--
    return current

  }

  getPlaylist() {
    const playlist = []
    let current = this.top
    while (current) {
      playlist.push(current.value)
      current = current.next
    }
    return playlist
  }
}

Solución… 😄
.
.
.
.

.
.
node.js:

export class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

.
exercise.js:

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    let newSong = new Node(song);

    if (!this.top) {
      this.bottom = newSong;
      this.top = newSong;
    } else { 
      newSong.next = this.top;
      this.top = newSong;
    }

    this.length++;
    return this;
  }

  playSong() {
    if (!this.top) { 
      throw new Error("No hay canciones en la playlist");
    }

    if (this.top === this.bottom) { 
      this.bottom = null;
    }

    let actualSong = this.top.value;

    this.top = this.top.next;
    this.length--;
    return actualSong;
  }

  getPlaylist() {
    let list = [];
    let actual = this.top;

    while (actual) {
      list.push(actual.value);
      actual = actual.next;
    }

    return list;
  }
}
export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newNode = new Node(song);
    if (this.length === 0) {
      this.top = newNode;
      this.bottom = newNode;
    } else {
      newNode.next = this.top;
      this.top = newNode;
    }
    this.length++;
  }

  playSong() {
    if (this.length === 0) {
      throw new Error("No hay canciones en la playlist");
    }
    const song = this.top.value;
    if (this.top === this.bottom) {
      this.bottom = null;
    }
    this.top = this.top.next;
    this.length--;
    return song;
  }

  getPlaylist() {
    const playlist = [];
    let currentNode = this.top;
    while (currentNode) {
      playlist.push(currentNode.value);
      currentNode = currentNode.next;
    }
    return playlist;
  }
}

El error de “Eliminar el siguiente al reproducir” es demasiado criptico, me ha costado un rato y estar apunto de tirar la toalle el darme cuenta de que lo que queria decir en realidad es "si solo queda un elemento en la lista, poner botttom a null.
.
.
.
.
.
.
.
.
.
.
.
.

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newNode = {
      value: song,
      next: null
    }

    if (!this.bottom) {
      this.bottom = newNode;
      this.top = newNode;
    } else {
      const prevTop = this.top;
      this.top = newNode;
      this.top.next = prevTop;
    }

    this.length++;
  }

  playSong() {
    if (!this.top) {
      throw new Error("No hay canciones en la playlist");
    }

    if (this.top === this.bottom) {
      this.bottom = null;
    }

    const currentTop = this.top.value;
    this.top = this.top.next;
    this.length--;

    return currentTop;
  }

  getPlaylist() {
    const playlistArr = [];

    let currentNode = this.top;
    while (currentNode) {
      playlistArr.push(currentNode.value);
      currentNode = currentNode.next;
    }

    return playlistArr;
  }
}

Mi solución:
.
.
.
.
.
.
.
.
.
.
código node.js:

export class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

código exercise.js:

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newNode = new Node(song);
    if (this.length === 0) {
      this.top = newNode;
      this.bottom = newNode;
    } else {
      newNode.next = this.top;
      this.top = newNode;
    }

    this.length++;

    return this
  }

  playSong() {
    if (this.length == 0) {
      throw new Error("No hay canciones en la playlist");
    }
    const songTop = this.top.value;

    if (this.top === this.bottom) {
      this.bottom = null;
    }

    this.top = this.top.next;
    this.length--;

    return songTop;
  }

  getPlaylist() {
    let playList = [];
    let currentNode = this.top;
    while (currentNode) {
      playList.push(currentNode.value);
      currentNode = currentNode.next;
    }
    return playList;
  }
}

Acá mi solución, muy parecida a la del resto. Ojo que el error que se debe mostrar no es “No hay canciones en la lista”, sino “No hay canciones en la playlist”. Ahora si la solución:
.
.
.
.
.
.
.
.
.
.

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom  = null;
    this.length  = 0;
  }

  addSong(song) {
    const newSong = new Node(song);
    if (!this.top) {
      this.top = newSong;
      this.bottom = newSong;
    }
    else {
      newSong.next = this.top;
      this.top = newSong;
    }

    this.length++;
    return this;
  }

  playSong() {
    if (!this.top) throw new Error("No hay canciones en la playlist");

    const lastSong = this.top;

    this.top = this.top.next;
    if (this.length === 1) this.bottom = null;
    this.length--;
    return lastSong.value;
  }

  getPlaylist() {
    if (!this.top) return [];
    let currentSong = this.top;
    const playList = [];
    playList.push(this.top.value);

    while (currentSong.next) {
      playList.push(currentSong.next.value);
      currentSong = currentSong.next;
    }

    return playList;
  }
}

Resolución del ejercicio jejej

.
.
.
.
.
.
.
.
.
.
.
.

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null
    this.bottom = null
    this.length = 0
  }

  addSong(song) {
    const newSong = new Node(song)
    if (this.length === 0) {
      this.top = newSong
      this.bottom = newSong
    }
    else {
      newSong.next = this.top
      this.top = newSong
    }
    this.length++
    return this
  }

  playSong() {
    if (this.length === 0) throw new Error("No hay canciones en la playlist")

    const removeSong = this.top
    this.top = this.top.next

    if (this.length === 1) this.bottom = null

    this.length--
    return removeSong.value
  }

  getPlaylist() {
    let count = this.length
    const arraySongs = []
    let tempSong = this.top
    while (count > 0) {
      arraySongs.push(tempSong.value)
      tempSong = tempSong.next
      count--
    }

    return arraySongs
  }
}

🛡️🛡️🛡️Escudo anti spoilers🛡️🛡️🛡️

Crea un stack para una playlist

Nunca pares de aprender 🦾

Node.js

export class Node {
  constructor(value) {
    this.value = value
    this.next = null
  }
}

exercise.js

import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
    const newSong = new Node(song);
    if (!this.top) {
      this.top = newSong
      this.bottom = newSong
      console.log(this);
    }
    else {
      newSong.next = this.top
      this.top = newSong
    }
    this.length++;
    return this
  }

  playSong() {
    if (!this.top) {
      throw new Error("No hay canciones en la playlist")
    }
    if (this.top == this.bottom) {
      this.bottom = null
    }
    const playedSong = this.top.value
    this.top = this.top.next
    this.length--;
    return playedSong
  }

  getPlaylist() {
    const playList = []
    if (!this.top) {
      return []
    }
    if (this.top) {
      playList.push(this.top.value)
      console.log(this.top.value)
      let currentSong = this.top
      while (currentSong.next) {
        playList.push(currentSong.next.value)
        currentSong = currentSong.next
      }
    }
    return playList
  }
}

**Hola dejo mi codigo con explicaciones de cada operador, explicado con detalles, ya que los uso para repasar conseptos basico de codigo **
Mi solucion es :
.
.
.
.
.

//node.js
export class Node {
  constructor(value) {
    this.value = value;
    this.next = null;
  }
}

.

//exercise.js
import { Node } from "./node";

export class Playlist {
  constructor() {
    this.top = null;
    this.bottom = null;
    this.length = 0;
  }

  addSong(song) {
//crea un nuevo objeto Node con el valor de song
    const newNode = new Node(song);

    if (this.length === 0) {
//Si la pila está vacía, el nuevo nodo se establece como el top y el bottom de la pila
      this.top = newNode;
      this.bottom = newNode;
    } else {
//De lo contrario, el nuevo nodo se agrega en la parte superior de la pila
      newNode.next = this.top;
      this.top = newNode;
    }
//actualizo la longitud de la pila 
    this.length++;
//regreso la pila actualizada 
    return this
  }

  playSong() {
    if (this.length == 0) {
//Si la pila está vacía, se lanza un error indicando que no hay canciones en la pila
      throw new Error("No hay canciones en la playlist");
    }
//De lo contrario, se obtiene el valor del nodo superior de la pila y se almacena en la variable songTop
    const songTop = this.top.value;

    if (this.top === this.bottom) {
//Si el nodo superior y el nodo inferior son iguales, el nodo inferior se establece en null
      this.bottom = null;
    }
//el nodo superior se establece en el siguiente nodo y la longitud de la pila se reduce en 1.
    this.top = this.top.next;
    this.length--;

    return songTop;
  }

  getPlaylist() {
//iniciamos el ARR , para llenarlo
    let playList = [];
//apuntamos al tope de la pila 
    let currentNode = this.top;

    while (currentNode) {
//mientras currentNode no sea null, se agrega el valor del nodo actual a la ARR playList y se establece currentNode en el siguiente nodo
      playList.push(currentNode.value);
      currentNode = currentNode.next;
    }
//regreso el Arr
    return playList;
  }
}
undefined