Jump to content

can someone help me get this javascript piece to work?

Hi so recently i have been trying to learn javascript and python on codeacadamy and so far i have been stuck on this question for a while now and i don't know what im doing wrong. Can someone help me and explain what i did wrong in the script? I have tried using the hint button and it didn't really help me out that much. This is the question i have to answer. Complete the missing bits of code to construct the if / else statement. Make the condition evaluate to true. Finish the else statement by printing out the string "Error Error Error" to the console. 

 

here is my script. when i hit run it throws me a SyntaxError: Unexpected token )

if ("Jon".length * 2 / (2+1) === ) {
{
    console.log("The answer makes sense!");

} else }
    console.log("Error Error Error");

"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." -Albert Einstein

Link to comment
Share on other sites

Link to post
Share on other sites

Your brackets around else are wrong. Also, what is === comparing to in your if statement? 

PSU Tier List | CoC

Gaming Build | FreeNAS Server

Spoiler

i5-4690k || Seidon 240m || GTX780 ACX || MSI Z97s SLI Plus || 8GB 2400mhz || 250GB 840 Evo || 1TB WD Blue || H440 (Black/Blue) || Windows 10 Pro || Dell P2414H & BenQ XL2411Z || Ducky Shine Mini || Logitech G502 Proteus Core

Spoiler

FreeNAS 9.3 - Stable || Xeon E3 1230v2 || Supermicro X9SCM-F || 32GB Crucial ECC DDR3 || 3x4TB WD Red (JBOD) || SYBA SI-PEX40064 sata controller || Corsair CX500m || NZXT Source 210.

Link to comment
Share on other sites

Link to post
Share on other sites

Just moved around the brackets.

 

if ("Jon".length * 2 / (2+1) === ) {
    console.log("The answer makes sense!");
else {
    console.log("Error Error Error");

}

Link to comment
Share on other sites

Link to post
Share on other sites

56 minutes ago, Gamin_M@t said:

Just moved around the brackets.

 

if ("Jon".length * 2 / (2+1) === ) {
    console.log("The answer makes sense!");
else {
    console.log("Error Error Error");

}

this should still throw an error as you're not comparing it to anything.

 

also there is no need for 2/(2+1) unless you plan on replacing then with variables just put the number you want to times by.

 

remember you order of operations too

(2+1) = 3

3*2 = 6

6/3 = 2

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

14 minutes ago, vorticalbox said:

this should still throw an error as you're not comparing it to anything.

 

also there is no need for 2/(2+1) unless you plan on replacing then with variables just put the number you want to times by.

 

remember you order of operations too

(2+1) = 3

3*2 = 6

6/3 = 2

2/3*

PSU Tier List | CoC

Gaming Build | FreeNAS Server

Spoiler

i5-4690k || Seidon 240m || GTX780 ACX || MSI Z97s SLI Plus || 8GB 2400mhz || 250GB 840 Evo || 1TB WD Blue || H440 (Black/Blue) || Windows 10 Pro || Dell P2414H & BenQ XL2411Z || Ducky Shine Mini || Logitech G502 Proteus Core

Spoiler

FreeNAS 9.3 - Stable || Xeon E3 1230v2 || Supermicro X9SCM-F || 32GB Crucial ECC DDR3 || 3x4TB WD Red (JBOD) || SYBA SI-PEX40064 sata controller || Corsair CX500m || NZXT Source 210.

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, djdwosk97 said:

2/3*

the length of job is 3

 

3*2/(2+1) with BODMAS/PEDMAS would be just as I said. Multiplication comes before division just for going left to right.

Edit:

 

console.log("jon".length * 2 / (2+1));
2

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×