• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

138
Vistas
la tarea es cambiar el método getEpisodeInfo() de la clase PodcastEpisode. Más detalles-----

Todavía nuevo en Javascript... todavía aprendiendo...

la tarea es cambiar el método getEpisodeInfo() de la clase PodcastEpisode, para que devuelva la duración del episodio en un formato más comúnmente aceptado.

 function getEpisodeInfo(){ return `${this.artist}. "${this.title}" - ${this.guest} ${this.getFormattedDuration()}`; } class PodcastEpisode { constructor(title, artist, guest,duration){ this.title = title; this.artist = artist; this.guest = guest; this.duration = duration; this.getEpisodeInfo =getEpisodeInfo } like(){ this.isLiked = this.isLiked; } getFormattedDuration() { const minutes = Math.floor(this.duration / 60); // the total number of minutes const seconds = this.duration % 60; // the remainder of the division by 60 return `${minutes}:${seconds > 9 ? seconds : "0" + seconds}`; } }
almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Supongo que solo está tratando de mover la función getEpisodeInfo a la Clase.

Pero no puede usar la palabra clave de function dentro de la clase para definir un método.

Aquí está el código completo:

 class PodcastEpisode { constructor(title, artist, guest, duration) { this.title = title; this.artist = artist; this.guest = guest; this.duration = duration; } like() { this.isLiked = true; } getFormattedDuration() { const minutes = Math.floor(this.duration / 60); // the total number of minutes const seconds = this.duration % 60; // the remainder of the division by 60 return `${minutes}:${seconds > 9 ? seconds : "0" + seconds}`; } getEpisodeInfo() { return `${this.artist}. "${this.title}" - ${this.guest} ${this.getFormattedDuration()}`; } }

Ahora puede crear un objeto PodcastEpisode y llamar a podcast.getEpisodeInfo().

Avísame si eso no es lo que estás tratando de hacer.

almost 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda