DevYoon
[프로그래머스] 폰켓몬 (Javascript) 본문
link ⛓ https://school.programmers.co.kr/learn/courses/30/lessons/1845
function solution(nums) {
var answer = 0;
let obj = {};
let N = nums.length /2;
nums.map(item => {
if(obj[item]){
obj[item] += 1;
}else{
obj[item] = 1;
}
})
const obj_length = Object.keys(obj).length;
if(obj_length <= N){
return obj_length;
}else{
return N
}
return answer;
}