Uses map object to hold the values we are looking for, and sets the key value as the index. When we find the number we're looking for, we return the index of the item (i) and our saved index

```
var twoSum = function(nums, target) {
const hashMap = new Map();
const result = [];
for (let i = 0; i < nums.length; i++) {
if (hashMap.has(nums[i])) {
result.push(i, hashMap.get(nums[i]))
} else {
let sumVal = target - nums[i];
hashMap.set(sumVal, i);
}
}
return result;
};
```