4. I have to celebrate you baby


#1


4. I have to celebrate you baby


The code works and returns the correct answer but it tells me that I have to use a switch statement, which i clearly do.


var name = prompt('Which movie are you searching for?');

var getReview = function (movie) 
{
 
 switch(name)
    {
    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();


#2

When you use you function, you put nothing in it. So it wouldn`t work without condition


#3

var movie = prompt("What movie would you like the review for?");

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!";
}
};

No idea what's wrong but it won't take it. Have been making little changes for an hour


#4

I tried using prompt but it wouldnt let me through, It says I should use a Switch statement so I deleted it, and you forgot to call it at the bottom, If you're stuck here's the solution

Try this :slight_smile:
Goodluck

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;

}
};
getReview("The Lion King");


#5

I tried it, But I have no Idea why It wont work.
this is my code,

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("Toy Story 2");

I have no idea whats wrong, please help


#6

Maybe it's just missing dot after "prospector" word? :slight_smile:


#7

This is what worked for me:

var movie = prompt("Which movie would you like the review of?")
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!");
}

};


#8

Use movie instead of name in your switch command and prompt


#9

Yeah, thats what it was. i couldn't see it for some reason. Thanks Bud!


#10

Thanks its working for me


#11

After so many times trying this code worked for me, use return instead of console.log, as the hits said "Because we are defining a function, we can make use of the return keyword!"

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!");
}
};


#13

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