I Have to Celebrate You Baby


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

https://www.codecademy.com/courses/spencer-sandbox/0/4?curriculum_id=506324b3a7dffd00020bf661#

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

My code is printing both “Cool animation, and funny turtles”(Finding Nemo) AND “Great story. Mean prospector.”. Additionally, the error message says “Are you sure you’re returning the right thing?” It’s returning TWO things, but only one of them is right. What could possibly be wrong with my code?


var getReview = function (movie) {

switch(movie) {
    case "Toy Story 2":
       console.log ("Great story. Mean prospector.");
        break;
        
    case "Finding Nemo":
        console.log("Cool animation, and funny turtles");
        break;
        
    case "The Lion King":
        console.log("Great songs");
        break;
        
    default:
        console.log("I don't know!");
        break;
    }
};

getReview("Finding Nemo");


#2

Hi @ajaxwhiz51084,

You’re supposed to use return instead of console.log.

Write a function named getReview that takes in a movie name and returns its review based on the information above. If given a movie name not found just return “I don’t know!”.

Hint: Make sure that what you return matches the case of the review text

Your code should be something like this:

var getReview = function (movie) {
  switch(movie) {
      case "Toy Story 2":
          return "Great story. Mean prospector.";
    
      case "Finding Nemo":

      //the rest of the code......

   }
}

Cheers :slight_smile:


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.