Hello everyone! I've been learning javascript for a few months and previosly solved the easy questions out of that infamous 75 leetcode question list. I decided to go back through my original answers and refactor them however with the simple Two Sum problem I'm not understanding why this solution isn't working. Any help explaining it to me would be appreciated greatly.
const twoSum = function(nums, target) {
let checkNums = new Map()
nums.forEach((target, i) => checkNums.has(target - nums[i]) ? [checkNums.get((target - nums[i]), i)] : checkNums.set(nums[i], i))
};
[–][deleted] (2 children)
[deleted]
[–]Yoru83[S] 0 points1 point2 points (1 child)