What else can I do?


#1

I'm up to exercise 19 and I have no idea what to do now I've done everything I thought possible. so far I've done:
if ('condition') {
("Jon".length * 2 / (2+1) === 2 );
}
console.log("The answer makes sense!");
}
else
{
console.log("the answer makes no sense!");
}

AND THE QUESTION W/ INSTRUCTIONS:
Math
We saw basic math before. The basic math symbols we learned in school work here. Even the order in which the computer understands the math is the same as in school!

Code:

  1. ( ): control order of operations
  2. * and /: multiplication and division
  3. and +: subtraction and addition

Examples:

  1. 100/10 evaluates to 10
  2. "Jane".length + 5 evaluates to 9
  3. 5*(3+1) evaluates to 20

Instructions
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.
?
Hint
There is a lot of left out syntax. The if keyword and the { } after the else keyword are all left out.

Make sure not to delete any of the provided code. It could cause your code to fail!

ORIGINAL CODE:
("Jon".length * 2 / (2+1) === )
{
console.log("The answer makes sense!");
}
else


#2

Hi put this

"Jon".length * 2 / (2+1) === 2

inside the () here

if ('condition')

remove 'condition' and put it without ' '


#3

I tried but don't understand completely. check out my updated question.


#4

YOu begin with that code

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

you know that the if and else statement have that structture

if (condition) {
   #do something
}
else {
   #do something
}

The if statement

what's missing to it

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

Can you find it?

Hint

it's missing the key if

if  ("Jon".length * 2 / (2+1) === )

and after the === you should put 2 WHy?

Because

the result of

"Jon".length * 2

is 6
the you have

6 / (2+1)

which is equale to 2 so if you put 2 after === you will have

if (2 === 2)

and the if statement will be true

else statement

you just need to close it and add the console.log()


#5

tells me there's something wrong with the syntax


#6

can you post your new code?


#7

("Jon".length * 2 / (2+1) === 2 )
{
console.log("The answer makes sense!");
}
else {
console.log("the answer doesn't make sense");
}


#8

It's missing if before the condition so it should be

if ("Jon".length * 2 / (2+1) === 2 )
{
    console.log("The answer makes sense!");
} 
else {
    console.log("the answer doesn't make sense");
}

#9

Oh yeah of course. Can't believe i didn't see that, thanks. I finished it.


#10

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