首页 > 求助,为什么return undefined??
头像
老头真猛
编辑于 2021-03-12 16:19
+ 关注

求助,为什么return undefined??


var arr = [0, 1, 2, 3, 4, 5, 7];
      findTheLost = (arr) => {
        let tempArr = [];
        if (arr.length === 2) {
          var result = parseInt(arr[0]) + 1;
          console.log(result);
          return result;
        }
        if (arr[Math.floor(arr.length / 2) - arr[0]] > arr.length / 2) {
          tempArr = arr.slice(0, Math.floor(arr.length / 2));
          
          findTheLost(tempArr);
        } else {
          tempArr = arr.slice(Math.floor(arr.length / 2), arr.length);
          
          findTheLost(tempArr);
        }
      };
      var temp = findTheLost(arr);
      console.log(temp);

全部评论

(0) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

近期热帖

近期精华帖

热门推荐