任务是更改 PodcastEpisode class 的 getEpisodeInfo() 方法。更多细节 - - -

the task is to change the getEpisodeInfo() method of the PodcastEpisode class. More details-----

对Javascript还是陌生的..还在学习..

任务是更改 PodcastEpisode class 的 getEpisodeInfo() 方法,以便 return 以更普遍接受的格式显示剧集持续时间。

 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}`; 
}
 
}

我猜您只是想将 getEpisodeInfo 函数移动到 Class.

但是,您不能在 class 中使用 function 关键字来定义方法。

完整代码如下:

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()}`;
    }

}

现在您可以创建 PodcastEpisode 对象并调用 podcast.getEpisodeInfo()。

如果这不是您想要做的,请告诉我。