Code Your Own Adventure 2!


#1

hi all,

im currently doing the second code adventure when you have to use a switch in the code. i have created my switch and everytime i run the code and select a answer, it just outputs my default with every answer. It lets me go the next screen anyway but then i dont understand whats going on.

var user = prompt("what is your favourite colour? Red, Blue, Pink").toUpperCase();

switch(user) {
case 'Red':
console.log("It looks like blood!!");
break;
case 'Blue':
console.log("It is the colour of the sky!!");
break;
case 'Pink':
console.log("do you want a tutu?!?");
break;
default:
console.log("Pick 1 of the 3 colours!");
}


#2

HI this line

var user = prompt("what is your favourite colour? Red, Blue, Pink").toUpperCase();

you upperCase the user answer so you should uppercase all your case

case 'RED':
  ...
break;
case 'BLUE':
   ...
break;
...

#3

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