var i = 0
function find (arr, value) {
while (i < arr.length) {
if (arr[i] == value) {
alert( i );
break;
}
alert( "-1" );
}
}
arr = ["test", 2, 1.5, false];
find(arr, "test"); // 0
find(arr, 2); // 1
find(arr, 1.5); // 2
find(arr, 0); // -1
dmFyIGkgPSAwCmZ1bmN0aW9uIGZpbmQgKGFyciwgdmFsdWUpIHsKCXdoaWxlIChpIDwgYXJyLmxlbmd0aCkgewoJaWYgKGFycltpXSA9PSB2YWx1ZSkgewoJCQlhbGVydCggaSApOwoJCQlicmVhazsKCX0KCWFsZXJ0KCAiLTEiICk7Cn0KfQoKCgphcnIgPSBbInRlc3QiLCAyLCAxLjUsIGZhbHNlXTsKCmZpbmQoYXJyLCAidGVzdCIpOyAvLyAwCmZpbmQoYXJyLCAyKTsgLy8gMQpmaW5kKGFyciwgMS41KTsgLy8gMgoKZmluZChhcnIsIDApOyAvLyAtMQ==