4. I have to celebrate baby -


#1


I don't know what I'm missing. It returns the answers I don't know!
Great story. Mean prospector.


Oops, try again. Are you sure you're returning the right thing?


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


#2

Try to delete the last line (getReview(answer)) and remove the last semi - colon so it should look like so:

console.log("I don't know!");
}
}


#3

Thank you. I did that but now I'm still getting the same error with correct response in the box.

Great story. Mean prospector.

Oops, try again. Are you sure you're returning the right thing?


#4

Weird. for me it works.
Are you sure you typing it right?


#5

Yup. 2nd time all I did was delete what you said.


#6

Basically what you need to have there, is that:

var name = prompt("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:
console.log("I don't know!");
}
}


#7

When I ran the above code, I received the following console error:

ReferenceError: answer is not defined.

It looks like you define something called "name", but not "answer". I have changed the code to say:

getReview(name);

But then, I keep getting the correct reply, but the first case reply as well. Example, for The Link King, I get:

Great songs.
Great story. mean prospector.

So I looked at your code, again. And I looked at the instructions:

Imagine you have a movie collection, and you want to write code that returns your review for each one.

The instructions are asking you to return a value, not print it out to the console. I removed all "console.log()" instances with "return"

var name = prompt("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(name);

Now, the console only prints one statement, and I'm allowed to move on to the next lesson. While your code was correct as far as function(al), you were not following CodeCademy's instructions, which is what your code is tested for. Try to watch out for that.


#8

Having the semi-colon after the statement below doesn't really affect the code posted. It is actually good coding practice to keep it there, albeit optional.

var getReview = function(movie){
[...]
};

For more information on when semi-colons are optional, obligatory, or should be avoided, check the following Codecademy guide:
Your Guide to Semicolons in JavaScript


#9

You code is good. But.
You declared a variable "name" where you stored the user input from prompt;
var getReview = function (movie) <-- you're supposed to change this "movie" to "name";
if you don't, movie will be "undefined"
(undefined means you declared the variable but you didn't give it any value);

So when you call your function,
getReview(answer);<--- you're supposed to change answer to "name"
(Why? answer you created holds no value; its an undefined argument in that parameter)
Now all you need to do is run

getReview(name)

Thats all :wink:


#10

("Toy Story 2, Finding Nemo, or The Lion King"); FOLSE

("Toy Story 2" , "Finding Nemo" , "The Lion King"); TRUE


#11

Correct Answer


Try your input as "The Lion King" & Change your function call getReview(answer); to getReview(name);

It is bug in Codecademy,
* For some people Unless your Input is "The Lion King" and the Output is "Great Songs." -> You wont be clearing the level.
* For some people Unless your Input is "Toy Story 2" and the Output is "Great story. Mean prospector." -> You wont be clearing the level.
* For some people Unless your Input is "Finding Nemo" and the Output is "Cool animation, and funny turtles." -> You wont be clearing the level.


getReview(name);
name - is the variable which gets the user input.


In order to finish this lesson. Try your input as "The Lion King". you will be cleared off.

Note:

There is no need to remove semicolon as other user suggested.

Cheers!!


#12

what to do? I keep getting "check the review of toy story 2"
below is my code. Thanks!

var name = prompt ("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!";
        break;
    }
};
getReview(name);

#13

@erinyleeyahoo.com - Try your input as "Toy Story 2". you will be cleared off, & No Break statement needed in Default case & Full Stop Missing in Return Statement. Check the code and comment below.

var name = prompt ("Toy Story 2, Finding Nemo, or The Lion King");
var getReview = function (movie) {
switch (movie) {
    case "Toy Story 2" :
        return "Great story. Mean prospector." ; // Mean prospector. "Full Stop is needed - other wise error" LOL
        break;

    case "Finding Nemo":
        return "Cool animation, and funny turtles." ;// funny turtles. "Full Stop is needed - other wise error" LOL
        break;

    case "The Lion King":
        return "Great songs." ; //Great songs. "Full Stop is needed - other wise error" LOL
        break;

    default:
        return "I don't know!";
      //  break; No need of break statement in default
    }
};
getReview(name);

Note:

  • No need of break statement in default switch case - i have commented that part.
  • Full Stop needed in return statement as mentioned in the problem. It is Good Practice to display what is asked, since it helps you in understanding the customer requirement better in future when you are developing in company. Even if the full stop is missing still it is not what they asked you to print. SO BE CAREFUL!!.
  • When you are prompted for input, try "Toy Story 2".. you will be clearing the level. Code is good.

#14

Hi, I am sorry, but what's a "full stop"?? Did you mean to put quotation marks around each title inside the prompt ()?


#15

Hello, no quotation in prompt()...
Fullstop is period, dot ( . ) ...
" . " -> Full Stop a.k.a Period.. to end a sentence in english..
They have asked you to print "Great songs." not "Great songs" etc in return statement --- > you have missed that '.' in the return statement.


#16

Thanks. BUT it didn't work. Now i am getting " syntax error: missing ) after the argument list"...
Below is my code. Thank you a bunch!!!

ar name = prompt(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(name);

#17

The code works if you put the quotation marks into the prompt statement (prompt("Toy Story 2 , Finding Nemo , or The Lion King"):wink:. Also, the Toy Story 2 case was not copied exactly, it needed a space between the M and the period ("Great story. Mean prospector.").


#18

Sorry, it auto corrected the semi-colon and close bracket to an emoji.


#19

Correct Code

var name = prompt ("Toy Story 2, Finding Nemo, or The Lion King");
var getReview = function (movie) {
switch (movie) {
    case "Toy Story 2" :
        return "Great story. Mean prospector." ; // Mean prospector. "Full Stop is needed - other wise error" LOL
        break;

    case "Finding Nemo":
        return "Cool animation, and funny turtles." ;// funny turtles. "Full Stop is needed - other wise error" LOL
        break;

    case "The Lion King":
        return "Great songs." ; //Great songs. "Full Stop is needed - other wise error" LOL
        break;

    default:
        return "I don't know!";
      //  break; No need of break statement in default
    }
};
getReview(name);

#20

Thank you for your help but I did what you had suggested and was still stuck. Finally I had to remove the prompt variable to clear.