Code your own adventure2


please help debugging??

var userAnswer = prompt(“Hi, do you want to play with doraemon, , nobita, or suzuka?”).toUpperCase();

case ‘doraemon’:
var gadgets= prompt(“are you interested in using gadgets”).toUpperCase();
var playfair= prompt(“or you don’t want help”).toUpperCase();
if (gadgets===‘yes’&& playfair===‘yes’) {
console.log(“great, let’s start”);
} else {
console.log(“good choice”);

case 'nobita':
    var dumbo= prompt("do you want some help").toUpperCase();
    var lucky= prompt("do you think he will manage,but needs some points").toUpperCase();
    if (dumbo==='yes'&& lucky==='yes') {
        console.log("he will definitely win");
    } else {
        console.log("Sorry, choose your player again");
case 'suzuka':
    var pretty= prompt("do you think she is pretty?").toUpperCase();
    var smarty= prompt("do you think she can win?").toUpperCase();
    if (pretty==='yes'||smarty==='yes') {
        console.log("very good choice);
    } else {
        console.log("you can change player");

    console.log("Sorry, you should choose between nobita, suzuka, and doraemon only);


  1. Use .toLowerCase() method because your cases have lower case values.
  2. You need to close string values:
console.log("very good choice); // missed " after word choice

console.log("Sorry, you should choose between nobita, suzuka, and doraemon only); // same thing after word only
  1. You need to close switch statement using }.


thaks alot,
It worked. But can’t we use freely .toLoweCase and .toUpperCase options.


We can use both methods. All JavaScript identifiers are case sensitive. So when we are using .toLowerCase() method case must be:

case 'doraemon'

and with .toUpperCase() method:


These methods you can use with string:


or with string variables:

var str1 = 'doraemon';
var str2 = str1 .toUpperCase();

So .toLowerCase() and .toUpperCase() are often using with prompt() to avoid mistakes.


A post was split to a new topic: Make sure to use a break statement with each case!