I'm stuck in this lesson! HELP!


#1



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

"oops try again. check the review of Toy Story2"

var user = prompt ("Enter your favorite movie").toLowerCase();
var getReview = function (movie) {
    
    
    switch (movie){
        
        case 'Toy Story2':
            return ("Great story. Mean prospector.");
            
         case 'Finding Nemo':
            return ("Cool animation, and funny turtles.");
           
        case 'The Lion King':
            return ("Great songs.");
          
        default:
            return ("I don't know!");
    }
};

getReview(user);

Continuing the discussion from 4.I have to celebrate you baby:


#2

Since you're using .toLowerCase() shouldn't be the case's in lowercase?


#3

Just removed the.toLowerCase , solved the whole thing!
thanks a lot !
:slight_smile:


#4

In fact, the way you did it was better, say a user choices "toy story2" (in lowercase) the case is there, but it wouldn't work. Using the toLowerCase function would help in those situations.


#5

so when i put .toLowerCase to the prompt statement like earlier , i have to include the movie names under switch statement in lowercase too??


#6

Yes! because you're comparing lowercase strings :slight_smile:


#7

For this exercise we should not be converting the case. It is improper. The data contains proper names that we should respect. Don't fudge data just to make your code work. That's a bad habit to start and will come with many hair pulling problems down the road.

Case parameters are data in the form of an expression.

The second thing to be aware of is the return values of prompt(). There are two possible returns, a string (may be empty) or null. The latter has no properties since it is not an object, so it cannot call a method it does not have in its prototype (also something it does not have, a prototype object).

If a user clicks Cancel or presses the Esc key, prompt() returns null. This will throw an exception and kill the program if we try to apply .toLowerCase() or .toUpperCase(). Always test the return for string type before applying any string (or object) methods on it.

    var user = prompt("...");
    if (user !== null) {
        // code here
    } else {
        console.log("Bye!");
    }

#9

thank you for the tip :slight_smile: