Closed Dr4gon closed 1 year ago
@echo75 The last two functions are exactly the same and the first is similiar. How would one general function for these look like?
user.js
reviewsMovie(imdbID) { const filteredReviews = this.reviews.filter(review => review.imdbID === imdbID) //console.log('filteredReviews', filteredReviews) const result = filteredReviews.length === 0 ? 'No reviews for this movie' : filteredReviews .map( (element, index) => `${index + 1}. ${element.text} -> Movie:(${element.imdbID}), says User: ${this.firstName}` ) .join('\n') return `--- Review-List ---\n${result}\n` } onWatch() { // onWatchInfo const result = this.watch === 0 ? 'No movies are put on the watch-list' : this.watch .map((element, index) => `${index + 1}. ${element.Title} (${element.Year}) (firstName: ${this.firstName})`) .join('\n') return `--- Watch-List ---\n${result}\n` } onWatched() { // onWatchedInfo const result = this.watched === 0 ? 'No movies are put on the watched-list' : this.watched .map((element, index) => `${index + 1}. ${element.Title} (${element.Year}) (firstName: ${this.firstName})`) .join('\n') return `--- Watched-List ---\n${result}\n` }
You could delete this methods as they are old getters and not used for the application
This was legacy code, that wasn't used - it is removed now
@echo75 The last two functions are exactly the same and the first is similiar. How would one general function for these look like?
user.js