function sumDigit(nums, target) { let mapping = {} for(let i = 0; i < nums.length; i++) { let n = nums[i] if(mapping[target - n] != null) return [ mapping[target - n], i ] mapping[n] = i } } sumDigit([3,2,4], 6)