I have to celebrate you baby - how do you add prompt?


#1


I have to celebrate you baby - https://www.codecademy.com/courses/spencer-sandbox/0/4?curriculum_id=506324b3a7dffd00020bf661#


I understand this exercise does not require a prompt. However I want to understand why I can't pass the variable into the function. How do I write this WITH input prompt... I do not understand why it does not work. In my current attempt I get the correct print out followed by "I don't know!"



var getReview = function (movie) {
switch(movie) {
    case 'TOY STORY 2': 
        console.log("Great story. Mean prospector.");
        break; 
    case 'FINDING NEMO': 
        console.log("Cool animatin, and funny turtles.");
        break;
    case 'THE LION KING': 
        console.log("Great songs.");
        break;
    default:
        console.log("I don't know!");
    }

};

var movie = prompt("Which movie do you wish to review?").toUpperCase();
getReview(movie);


#2

Hmmm still a problem without the prompt I get the same error....


#3

Hi @dragon81, Can you post raw code rather than snap ? use </> to format the code.


#4

var getReview = function (movie) {
switch(movie) {
case 'TOY STORY 2':
console.log("Great story. Mean prospector.");
break;
case 'FINDING NEMO':
console.log("Cool animatin, and funny turtles.");
break;
case 'THE LION KING':
console.log("Great songs.");
break;
default:
console.log("I don't know!");
}

};

var movie = prompt("Which movie do you wish to review?").toUpperCase();
getReview(movie);


#5

getReview(movie);

pass any movie name!


#6

yes I tried this, it did not work. that was the second screen shot

var getReview = function (movie) {
switch(movie) {
case 'TOY STORY 2':
console.log("Great story. Mean prospector.");
break;
case 'FINDING NEMO':
console.log("Cool animatin, and funny turtles.");
break;
case 'THE LION KING':
console.log("Great songs.");
break;
default:
console.log("I don't know!");
}

};

//var movie = prompt("Which movie do you wish to review?").toUpperCase();
getReview(FINDING NEMO);


#7

In the instruction..

It said you to return the strings?
but you're printing the strings?(using console.log() ?)


#8

hmmm I see, why does it double print if I use console.log()?


#9

Ok this works with prompt.

var getReview = function (movie) {
switch(movie) {
    case 'Toy Story 2': 
        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!";
    }

};

var movie = prompt("Which movie do you wish to review?");
getReview(movie);


#10

current issue solved?


#11

Yes when I change it to return I can enter with a prompt and it returns and is a pass. However I still wish to understand why I could not use console.log()


#12

Sure..

lets get back to instruction..

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!". Use a structure learned in an earlier lesson (NOT if/else statements) to write this function.

As we can see they explicitly mentioned to use return keyword.
(also edit your last working code(pic) so other does not just copy-paste :slight_smile: )


#13

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