Javascript, wtf?

timtadams

Landscape Designer
Joined
Sep 9, 2008
Messages
2,260
Location
Australia
Ive been messing about with Javascript the last couple of days. Ive come across numerous issues, and worked out nearly all of them myself with Google. Now i keep getting a syntax error on a certain line, and i cant see anything wrong with it! In fact, i never had a problem with this line before, and i havnt changed it since!

I thought that maybe i had missed a parenthesis or other character somewhere in the script, however, i tried the section of code by itself, and it still has the syntax error :( Im a bit annoyed as its a simple bit of code too

Ive simplified it heaps and it still gives an error (SyntaxError: syntax error, line: 8 )
Code:
for ( i = 1; i <= 20; i++);
  {
  RF = Math.round(Math.random());
  if (RF <= 0.43);
    {
    a=1;
    }
[B]  else[/B]
    {
    a=2;
    }
  alert(t)
  }

wth, its an 'else' statement?! Does anyone have any idea why this may be occurring and what i can do about it?
 

Hobbezak

Garden Designer
Joined
Dec 14, 2007
Messages
894
Location
Antwerp, Belgium
Ive been messing about with Javascript the last couple of days. Ive come across numerous issues, and worked out nearly all of them myself with Google. Now i keep getting a syntax error on a certain line, and i cant see anything wrong with it! In fact, i never had a problem with this line before, and i havnt changed it since!

I thought that maybe i had missed a parenthesis or other character somewhere in the script, however, i tried the section of code by itself, and it still has the syntax error :( Im a bit annoyed as its a simple bit of code too

Ive simplified it heaps and it still gives an error (SyntaxError: syntax error, line: 8 )
Code:
for ( i = 1; i <= 20; i++);
  {
  RF = Math.round(Math.random());
  if (RF <= 0.43);
    {
    a=1;
    }
[B]  else[/B]
    {
    a=2;
    }
  alert(t)
  }

wth, its an 'else' statement?! Does anyone have any idea why this may be occurring and what i can do about it?

drop the ; after if(RF <= 0.43);
That should fix the problem.
 

timtadams

Landscape Designer
Joined
Sep 9, 2008
Messages
2,260
Location
Australia
lmao

the problem occurred when i went through the whole script adding the colons i had left out (without paying much attention). So i went and removed them, but mustve missed something earlier, so i didnt think that was the problem :x ...now back to original coding to find perpetrator :p

cheers Hobbs

/me feels silly (i guess it is obvious i have never used javascript before :p)
 

Hobbezak

Garden Designer
Joined
Dec 14, 2007
Messages
894
Location
Antwerp, Belgium
lmao

the problem occurred when i went through the whole script adding the colons i had left out (without paying much attention). So i went and removed them, but mustve missed something earlier, so i didnt think that was the problem :x ...now back to original coding to find perpetrator :p

cheers Hobbs

/me feels silly (i guess it is obvious i have never used javascript before :p)

My usual rate is €850 per day. I will pm you shortly to arrange the conditions of payment.
 

Alcibiades

Plant Geneticist
Joined
Dec 13, 2007
Messages
4,267
Location
Canada
lmao

the problem occurred when i went through the whole script adding the colons i had left out (without paying much attention). So i went and removed them, but mustve missed something earlier, so i didnt think that was the problem :x ...now back to original coding to find perpetrator :p

cheers Hobbs

/me feels silly (i guess it is obvious i have never used javascript before :p)

My usual rate is €850 per day. I will pm you shortly to arrange the conditions of payment.

€850 worth of knee pads, right Hobbe?
 
  • Like
Reactions: Dax
Top