目标如下:
从数组[1,3,2,4,5,6,7]中找到比第1个位置大一丁点的元素
function _findIndex(arr, j){let k = -1;let key = arr[j];for(let i = j; i< arr.length; i++) {if(arr[i] > key) {if( k !== -1){if(arr[i] < arr[k]) {k = i;}} else {k = i;}}}return k
}
let arr = [1,3,2,4,5,6,7];
console.log(_findIndex(arr,0));