I need some math help with JavaScript

Started on the old forum in October 2012 · view the original in the archive · old links redirect here

4 replies · 1,669 views · started 14 years ago · 1 min read

3 participants
Glow Newbie · 4 posts #1

At the moment, I'm doing a lession of JavaScript. But I'm doing some math currently.

My question is : "

  1. Complete the missing bits of code to construct the if / else statement. Make the condition evaluate to true.
  2. Finish the else statement by printing out the string "Error Error Error" to the console."

What I have to fix is this : " Line 1: ("Jon".length * 2 / (2+1) === ) Line 2:{ Line 3: console.log("The answer makes sense!"); Line 4:} Line 5:else Line 6: Line 7: "

Help someone? 🙁

zain Junior · 43 posts #2

i think this should do it for you

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

{
 console.log("The answer makes sense!")
} 

else 

{
 console.log("Error Error Error")

}

anyways hope this helps

mansi Developer · 60 posts #3

Glow wrote: At the moment, I'm doing a lession of JavaScript. But I'm doing some math currently.

My question is : "

  1. Complete the missing bits of code to construct the if / else statement. Make the condition evaluate to true.
  2. Finish the else statement by printing out the string "Error Error Error" to the console."

What I have to fix is this : " Line 1: ("Jon".length * 2 / (2+1) === ) Line 2:{ Line 3: console.log("The answer makes sense!"); Line 4:} Line 5:else Line 6: Line 7: "

Help someone? :(

Use bracket before divide. ("jon".length*2)/etc.

Glow Newbie · 4 posts #4

zain wrote: i think this should do it for you

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

{
 console.log("The answer makes sense!")
} 

else 

{
 console.log("Error Error Error")

}

anyways hope this helps

With my first try, i pretty much did that, I think i missed out one of the brackets or something. But that worked. Thanks. 🙂

zain Junior · 43 posts #5

you had ; which would have not allowed the code to work 🙂

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close