Jump to content

Can arrays be used in an IF statement?


helpneeded22
 Share

Recommended Posts

I am brand new to Javascript, but I do have some programming experience. My code is not working and the only reason I can think of is that JS must not be able to evaluate an array in an IF statement? Here is a sample code:

<script type="text/javascript"> var mini01=["AMIRI","Rare","Medium","on","Announced","July 7, 2012"];var rarecolor="#000000";if (mini01[1]=="Common")  {  rarecolor="#008000";  }  elseif (mini01[1]=="Uncommon")  {  rarecolor="#0000ff";  }  else  {  rarecolor="#ffffff";  }document.write('<font color="' + rarecolor +'">');document.write(mini01[1]); </script> 

Nothing outputs. Any suggestions? (Note: I do close the FONT tag in html after the script)

Edited by helpneeded22
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...