Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-10-2012, 07:00 PM   PM User | #1
Dreyan
New to the CF scene

 
Join Date: Aug 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Dreyan is an unknown quantity at this point
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..
Dreyan is offline   Reply With Quote
Old 08-10-2012, 07:07 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,697
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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
}
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
Dreyan (08-10-2012)
Old 08-10-2012, 07:09 PM   PM User | #3
Dreyan
New to the CF scene

 
Join Date: Aug 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Dreyan is an unknown quantity at this point
Thanks

appreciate the quick response, i'll fix that now
Dreyan is offline   Reply With Quote
Reply

Bookmarks

Tags
beginner

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:32 PM.


Advertisement
Log in to turn off these ads.