Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Anyone tell me why this doesn't work? (It's incredibly easy and really short)

    I started learning this morning, and thought I'd try and make something using if/else, functions, console.log and variables, which is pretty much all i know so far. anyone tell me why this doesn't run/correct it?



    var guess=function()
    {
    var number=prompt("guess what number i'm thinking of between 1 and 100");
    }
    if(
    {
    number<77
    console.log("guess higher")
    guess();
    }
    else if
    {
    number>77
    console.log("guess lower")
    guess();
    }
    else if
    {
    number===77
    console.log"boom, nailed it"
    }
    guess();
    Last edited by Dreyan; 08-10-2012 at 07:09 PM.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,700
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    If you know what the console is and how to use it, you should have noticed it telling you that you have some kind of syntax error. The correct syntax is:
    Code:
    if(condition) {
      // do something
    }

  • Users who have thanked VIPStephan for this post:

    Dreyan (08-10-2012)

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thanks

    appreciate the quick response, i'll fix that now


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •