I am trying to create a function if an array of integers has duplicate values, so I came up with the following implementation, and it works:
const containsDuplicate = (nums) => {
const hashTable = {}
for (let num in nums) {
const numValue = nums[num]
if (numValue in hashTable) return true
hashTable[numValue] = "a"
}
return false
};
But, I want to know a semantic way to implement this following ES6 style, I tried the .forEach
but, I discovered that I cant break out of it.