Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions reto3-melissayauri/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/****** PILAS ******/
class Spotify{
constructor(){
this.elements = [];
}
// agregando elementos a la pila
addSongs(song){
this.elements.push(song);
return this.elements;
}
// quitar el ultimo elemento de la parte superior y a parte lo regresa
lastSong(){
return this.elements.pop();
}
// mostrando el elemento de la parte superior
topSong(){
return this.elements[this.elements.length-1]
}
// Validar si hay al menos una canción
// false = 0 elementos
validateSong(){
return this.elements.length>0;
}
deleteSongs(){
this.elements= [];
}
sizeSongs(){
return this.elements.length;
}
}

const spotify = new Spotify();
console.log(spotify.sizeSongs());
if(!spotify.validateSong()){
spotify.addSongs('la incondicional-Prince Royce');
spotify.addSongs('Mientes tan bien-Sin Bandera');
spotify.addSongs('Baby-Nicky Jam');
console.log(spotify.elements)
// muestra n° 3 al incorporan 3 canciones
console.log(spotify.sizeSongs());
// quita la última canción y lo muestra
let nickyJam = spotify.lastSong();
console.log(nickyJam)
//ahora muestra el elemento quedo en la parte superior
console.log(spotify.topSong());
// ahora eliminaremos todas las canciones
spotify.deleteSongs();
// validaremos que no exista ninguna canción
console.log(spotify.validateSong());
}
12 changes: 12 additions & 0 deletions reto3-melissayauri/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>