var twoSum = function(nums, target) { var list = []; for(var i=0;i<nums.length;i++){ let a = target - nums[i]; if(list[a] != undefined){ return [list[a],i] } list[nums[i]] = i; } };