I have an array that is going to contain about 400 things. Now I need to search for a specific item in the array and I was wondering if there was a more efficient way than a “for” loop and a “if” conditional in this for when the array matches the item I’m searching for. npicID is an ID that I get from the URL. Here is what I have:
var getPictureName = new array(400)
getPictureName(1) = “a1/smiley.gif”;
etc.
for (i = 0; i <= 400; i++) {
if (getPictureName(i) == npicID) {
var image= getPictureName(i);
var NS = (navigator.appName==”Netscape”)?true:false;
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
iHeight = (NS)?window.innerHeight:document.body.clientHeight;
iWidth = document.images[0].width – iWidth + 75;
iHeight = document.images[0].height – iHeight + 210;
window.resizeBy(iWidth, iHeight);
self.focus();
}
}
The above loop will work but it just seems like it will take forever and also be a waste of resources. Anyone know of a cleaner and more efficient process. Thanks.