Search code examples
javascriptfunctionconsole.logabstraction

How do I console.log only the highestRated rating and the Movie-title of highestRated rating


I have been trying to out only the rating and title of the movie but when consolelog highestRated I keep on getting the full object. How do I console.log only the highestRated rating and the Movie-title of highestRated rating

sample output;

highest rated : Joker (10)


Solution

  • To get highestRated rating and highestRated movieTitle

    // movieTitle
    console.log(highestRated.movieTitle);
    // rating
    console.log(highestRated.rating);
    
    // Output highest rated: Joker(10)
    console.log(`highest rated : ${highestRated.movieTitle} (${highestRated.rating})`);