Intro to Objects I. Isn't it better if I ask the user for a prompt?


#1

My code works out and all (before trying to make it not case sensitive)but wouldn't it be easier for the user to ask for a prompt first and make everything a uniform case? that way its not case sensitive?

How would I push everything to make it upper or lower case without using a prompt?


var getReview = function (movie).toLowerCase(); {
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('toy story 2');


#2

Do the instructions ask for a prompt statement? If not, then it doesn't matter. If we are asked to write a prompt, then it may be expected in the code when the lesson check takes place. Always follow instructions closely for best results in lessons.

Now from a program perspective, it makes perfect sense to take user input to drive the progrram. For this instance, be sure to not write it inside the function. Have the function call pass the user input in the argument.

var film_choice = prompt("Enter a movie title:")
console.log(getReview(film_choice))

Two things wrong in the above line. The semi-colon, and the string method on the parameter.

var getReview = function (movie) {

The movie titles given in the instructions must be used exactly as provided. There is no reason to change the case on the user inputs.


#3

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