Shoutbox

if somthing is element of an array - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: if somthing is element of an array (/showthread.php?tid=62064)

if somthing is element of an array by JonnyT on 06-29-2006 at 10:03 PM

is there an easy way to do somthing like:

if Green is an element of the color array do somthing

or basicly searching an array

Thanks Jon


RE: if somthing is element of an array by can16358p on 06-29-2006 at 10:10 PM

let arrays name  be colors, and you are searching for "green"
let exists be the boolean, if there is, it will be true.

var exists=false;
for(var i=0;i<colors.length;i++){
if(colors[i]=="green"){
exists=true;
}
}