喵喵时光机
最笨的方法可以用两层for循环计算const arr = [1,2,4,8,16,32];function addResult(arr,value){ let key = []; for(let i = 0; i < arr.length;i++){ let d = arr[i]; for( let j = 0; j < arr.length;j++){ let jd = arr[j]; if( d + jd === value ){ key = [i,j]; break; } } if( key.length > 0 ) break; } return key;}addResult(arr,4)