Given an array of integers, find if the array contains any duplicates.
Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.
객체를 만들고 이미 키 값이 있으면 즉시 return true. 모두 통과하면 return false
var containsDuplicate = function(nums) {
let obj = {};
for(let i of nums){
if(!obj[i]){
obj[i] = 1;
}else{
return true;
}
}
return false;
};