Please help me with my syntax?


#1

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

SyntaxError: Unexpected token '.'

var makeCash = prompt("What is your business here?").toUpperCase();{
    console.log(makeCash);
}

switch(makeCash) {
    case 'STOCKS':
         var MumDad = prompt("Are you happy with impressing mum and dad? (Yes or NO?)").toUpperCase();
    if(MumDad === 'YES') {
        console.log("Get the hell out of my office idiot!");
    } else {
        console.log("Hmmm, I am going to have to think about hiring you, FYI it's not looking promising for you!");
    }
        break;
    case 'OPTIONS':
        var BlackScol = prompt("Do you understand how to calulate option premiums?");.toUpperCase();
        var Exp = prompt("How many years experience do you have in (number) of years if you may?");
        if(BlackScol="YES" && Exp => 3){
            console.log("Nice work, I like your style your hired.");
        } else {
        console.log("Stop wasting my time and get out!");
        }
        break;
    case 'FUTURES':
        var WhatTrade = prompt("Are you trading something specific?").toUpperCase();
        var Spec = ["metals","oil","bonds","commodities","indexes"];
        var Pois = prompt("What's your poison?").toLowerCase();
//**I was not sure how to allow for a variety of response options, I tried to use an array but I am not sure I have done it correctly or weather it will work the way I would like it to. I would like it to prompt the user with "What's your poison?" and then accept any one of the 5 variables in the Spec array above as a correct answer. Some direction would be very helpful e.g. You need to use a loop etc. **
        if(WhatTrade === "NO" || Pois === Spec) {
            console.log("Your hired, how quickly can you start a 2 week trial?");
        } else { 
            console.log("Are you kidding me, get out you clown!");
        }
        break;
    case 'BONDS':
    var Bstr = prompt("How are you planning on trading the bonds?").toUpperCase();
    if(Bstr = "FUTURES"){
        console.log("We like your motivation, please wait for the interviews and we hope to call you back.");
        } else {
            console.log("Hahahahahahahaha, get out!");
        }
        break;
        default:
        console.log("Get out of my office, I'll see to it that your never interviewed again in this town!!!!!!");
        break;
}

As well is the error message I have also outlined an area where I was not really sure if I had taken the right action to complete a step.


#2

you put a semi colon right after your parentheses and before your .toUpperCase(). The computer is ending your statement and then reading the .toUpperCase and being confused. It should work if you remove that semicolon


#3

@iamtapanpatel
@durbinshire

I tried removing that and it came up with the error Unexpected string.


#4

Okay, well, i couldn't find the string error, but below me you should switch around the = and > signs

and you don't need to put a break; after the default at the end of the switch. That may help


#5

Thank you for pointing that out. Will fix that immediately. :smiley:


#6

var makeCash = prompt("What is your business here?").toUpperCase();{
console.log(makeCash);
}Changed to recommended

    if(BlackScol="YES" && Exp => 3){

changed to recommended

var BlackScol = prompt("Do you understand how to calulate option premiums?");.toUpperCase();
**After you pointed out the first error I noticed that I had made a similar mistake here. **

I also thought of a better way to test my code in the process. By using the /* */ and breaking up the code into sections and then testing it. Just added this because I thought it may help someone else if this post is referred to in future and they had not thought of it yet.

Thank you again for the help I really appreciate it.:smiley::smile_cat: