Need help,thanks


#1

var getReview = function (movie) {
if ("movie"="Toy Story 2"){
return "Great story. Mean prospector."
}
else if("movie"="Finding Nemo"){
return "Cool animation, and funny turtles."
}
else if("movie"="The Lion King"){
return "Great songs."
}
else{
return "I don't know!"
}
};

The codes returns with"ReferenceError: Invalid left-hand side in assignment".


#2

The two primary errors are,

  1. "movie" instead of movie; and,
  2. = instead of ===

Those two fixes should correct any running errors.

Is this exercise expecting a switch statement?


#3

@yuin_hsin,
You will have to use a so-called comparison operator, == or ===
and
you will compare to the variable movie
and not as you do, using comparing to a string "movie"
So change your

("movie"="Toy Story 2")

into

(movie==="Toy Story 2")

#4

Thank you


I have got a correct answer,but the system does not accept it.


#5

Please see my screenshot


#6

As suspected, the lesson checker is expecting a switch statement.

    switch (movie) {
    case "Toy Story 2": 
        return "Great story. Mean prospector.";
    
    default: "I don't know!";
    }

#7

Ha ha,that's the point,thank you.