I need some math help with JavaScript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    I need some math help with JavaScript

    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?

    #2
    i think this should do it for you
    Code:
    if ("Jon".length * 2 / (2+1) === 2)
    
    {
     console.log("The answer makes sense!")
    } 
    
    else 
    
    {
     console.log("Error Error Error")
    
    }
    anyways hope this helps

    Comment


      #3
      Originally posted by Glow View Post
      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.

      Comment


        #4
        Originally posted by zain View Post
        i think this should do it for you
        Code:
        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.

        Comment


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

          Comment

          Working...
          X