evenOccurrence
Written on August 24, 2019
문제
Find the first item that occurs an even number of times in an array. Remember to handle multiple even-occurrence items and return the first one. Return null if there are no even-occurrence items.
풀이
var evenOccurrence = function(arr) {
for (let i = 0; i < arr.length; i++) {
if (arr.filter(e => e === arr[i]).length % 2 === 0) {
return arr[i];
}
}
};
👩🏻💻 배우는 것을 즐기는 프론트엔드 개발자 입니다
부족한 블로그에 방문해 주셔서 감사합니다 🙇🏻♀️
in the process of becoming the best version of myself