nn2 nn2 - 3 months ago 40
Javascript Question

JavaScript is in array

Let's say I have this:

var blockedTile = new Array("118", "67", "190", "43", "135", "520");

There's more array elements but those are just few for readability purposes. Anyways, I could do a "for" loop but it would do 500 loops everytime you click on the map... is there any other way to see if a certain string is in an array?


Try this:

if(blockedTile.indexOf("118") != -1)
   // element found