求助,为什么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);

全部评论

相关推荐

投递华为等公司10个岗位
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务