版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

19 lines
257 B

  1. 'use strict';
  2. function arrayFind(arr, fn) {
  3. if (!Array.isArray(arr)) {
  4. return;
  5. }
  6. var idx = 0;
  7. while (idx < arr.length) {
  8. var result = fn(arr[idx]);
  9. if (result) {
  10. return result;
  11. }
  12. idx++;
  13. }
  14. }
  15. module.exports = arrayFind;