4. I have to celebrate you baby: don't understand error


#1



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


I'm returning the correct output to the console but an error is still appearing at the bottom saying "Oops try again. Better use a switch statement." And I have made the switch statement. This is the code I wrote:


var user = prompt("Which movie?: Toy Story 2, Finding Nemo, or The Lion King");

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

getReview(user);


#2

@jessbautista,
Try a refresh Browser
and use

console.log( getReview(user) );

++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


#3

Here is the right code for you

var movie = prompt("Which movie?: Toy Story 2, Finding Nemo, or The Lion King");

var getReview = function (movie) {

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

};

getReview(movie);


#4

If we use above code...we are getting this error "Oops, try again. Better use a switch statement".
so its better to Pass "movie " in switch statement


#5

the break; statement is NOT actually required according to me,because you are returning the statement,


#6

Hey thanks... Your answer was helpful (i sort of borrowed it...lol). Though i don't understand where my code was wrong.


#7

var user = prompt("Which movie?: Toy Story 2, Finding Nemo, or The Lion King");

var getReview = function (movie) {
    
    switch(user) {

not an expert, but you defined a var user, then function (movie) and used switch (movie).
I think the var should also be movie


#8