Exercise 9 problem on the result


#1

Hello !

I have a problem with my switch : the computer is always printing the 'default' choice even if I put a choice that appears in the list. Here is my code :

var fruits = prompt("What is your favorite fruit ?")

switch (answer) {
case 'apple':
console.log("I personnaly prefer the red ones !");
break;
case 'pineapple' :
console.log("Yellow, as the sun !");
break;
case 'strawberry' :
console.log("These are my favourite !");
break;
default :
console.log("Are you sure this is a fruit ?");
break;
}


#2

I'm not sure, but I think you should put fruits where answer is now

var fruits = prompt("What's your favorite fruit?");
switch(fruits){

#3

oh okey ill try for it thanks !


#4

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