Why is only option default?


#1

https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/6?curriculum_id=506324b3a7dffd00020bf661

There seems to be error in my adventure because no matter what i enter only thing i get is the default option. It seems to not be something big since i can go on but i would like to know why is this happening.


Replace this line with your code. 
var user = prompt('I need someone to share an adventure with. Are you in?(yes, no or maybe)').toUpperCase; 

switch (prompt){ 
    case 'yes': 
        var good = prompt('Great! Do you have a map?'); 
        var packing = prompt('Did you pack your things'); 
         if (good === "yes" && packing === "yes") {
             console.log('Great! Lets get going.');  
         } else if (good === "yes" || packing === "yes") { 
             console.log('Never mind, we will manage.'); 
         } else { 
             console.log('Then hurry up!'); 
         } 
        break; 
    case 'no': 
        var goodFun = prompt('Are you sure?'); 
        if (goodFun === "yes") { 
            console.log('Beg your pardon. Will be on my way.'); 
        }
        break; 
    case 'maybe': 
        var dance = prompt('Would me making you laugh change your mind?'); 
        if (dance === "yes") { 
            console.log('Doing the irish jig and split my pants'); 
        } else { 
            console.log('Party pooper!'); 
        }
        break;
    default: 
        console.log('Oh, we are already on our way. Tell me later.'); 
        break; 
}


#2

Hi there

var user = prompt('...?(yes, no or maybe)').toUpperCase;

Here you retrieve the user's answer. But don't forget you then convert their answer to an uppercase representation.

So down below in your cases, you need to test for exact string matches. 'yes' won't be the same thing as 'YES' for example. Make those changes and you should be good to go.

Let me know if you need anymore help.


#3

Already tried all options couple times before posting this. Also tried to change that part of code to lower case option but for every one i get default answer. I didn't get any error message or anything or i would know what is wrong.
Thanks anyway.


#4

Ah okay, my bad I should have looked a little closer. I found two more issues.

When you call the toUpperCase function you need to also include the parentheses. So..

var user = prompt('I ... you in?(yes, no or maybe)').toUpperCase;

becomes:

var user = prompt('I ... you in?(yes, no or maybe)').toUpperCase();

Finally in your switch statement, you need to test for the variable user, not prompt.

switch (prompt){

becomes:

switch (user){

That should clear it up.


#5

Yes! Thank you!!! It was the prompt thing. Such an stupid mistake, yet so much trouble. :slight_smile:


#6

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