What's wrong with my code?


#1


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


It doesn't show any errors, but after I try to run the program, the result is unsatisfied, the problem occurs when it comes to 'yes' and 'no' for each answer


var user = prompt("You are facing a troll and he's going to eat you. What would you like to do?FIGHT, RUN, OR PAY him?").toUpperCase();

switch (user) {
    case 'FIGHT':
        var strong= prompt("Are you strong enough?").toUpperCase;
        var smart= prompt("Are you smart?").toUpperCase;
        if (strong === 'YES' || smart==='YES') {
        console.log("You're either strong or smart, you can beat him easily!");
        }else {
        console.log("You're so dumb, You're gonna be eaten!");
        };
        break;
    case 'PAY':
        var money =prompt("Do you have much money?").toUpperCase;
        var cur = prompt("Do you have money in troll currency?").toUpperCase;
        if (money=== 'YES' && cur ==='YES') {
            console.log("Nice! Let's pay for that b*tch and get outa here");
        } else {
            console.log("Holy sh*t! How are you supposed to do with those pennies?");
        }
        break;
    case 'RUN':
        var run =prompt("Are you sure you can get away from him?").toUpperCase;
        if ( run) {
            console.log("Let's go")
        } else {
            console.log("Stay here and be eaten, nerd!")
        }
        break;
    default:
        console.log("Please choose the approriate answer!");

}


#2

Is it that toUpperCase is a function and needs parenthesis after it, like

.toUpperCase();

Looking at it that's the only thing that pops out.


#3

Yeah, it's a function which I use as the instruction given. I also changed the case with the sample, but I got the same result. If I change the whole code, the outcome will be different


#4

I just ran it, the problem is that you don't have parenthesis after your .toUpperCase functions. Rewrite every

.toUpperCase;

as

.toUpperCase();

Right now you aren't actually calling the function like you think you are, which is making variables like strong or smart have weird values. If you want to see what they are before you make the changes I said, add something like

console.log(smart + " " + strong);

after you get the input for the variables