Exercise 9 problem on the result


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 !");
case 'pineapple' :
console.log("Yellow, as the sun !");
case 'strawberry' :
console.log("These are my favourite !");
default :
console.log("Are you sure this is a fruit ?");


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

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


oh okey ill try for it thanks !


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