fork(1) download
  1. var i = 0
  2. function find (arr, value) {
  3. while (i < arr.length) {
  4. if (arr[i] == value) {
  5. alert( i );
  6. break;
  7. }
  8. alert( "-1" );
  9. }
  10. }
  11.  
  12.  
  13.  
  14. arr = ["test", 2, 1.5, false];
  15.  
  16. find(arr, "test"); // 0
  17. find(arr, 2); // 1
  18. find(arr, 1.5); // 2
  19.  
  20. find(arr, 0); // -1
Runtime error #stdin #stdout #stderr 0.01s 30424KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:5:3 ReferenceError: alert is not defined