function a(n) { if (n===1) { return [] } let a = []; let temp = [a]; while(n-- > 2) { a[0] = []; a =a[0] } return temp; } // console.log(JSON.stringify(a(4))) function get(target, arr) { for(let i = 0;i<arr.length;i++){ for(let j = 0;j<arr.length;j++){ if (i!==j && arr[i]+arr[j] === target) { return [i,j] } } } } console.log(11, get(12,[1,2,3,4,5,6,7]))