/** * @param {number[]} nums * @param {number} target * @return {number[]} */ var twoSum = function(nums, target) { var tatol = []; nums.map((item, index) => { if(item + nums[index + 1] === target) { // console.log(item, nums[index + 1]) total = [index, index + 1] // console.log(tatol) } }) console.log(tatol) }; var nums = [2,7,11,15], target = 9; twoSum(nums, target)