sortFunction 없을 경우, 오름차순/ASCII 문자 순으로 정렬
const array = [4, 11, 2, 10, 3, 1]
// 오름차순
array.sort((a,b) => a-b) // 1, 2, 3, 4, 10, 11
// 내림차순
array.srot((a,b) => b-a) // 11, 10, 4, 3, 2, 1
let platform = new Map([
['naver', "green"],
['kakao', "yellow"],
]);
for (let [k, v] of platform) {
return [k, v] // ['naver', "green"], ['kakao', "yellow"]
}
function solution(array) {
let counting = new Map();
let countArray = new Array;
let max = 0;
for(let i of array) {
if(!counting.has(i)) counting.set(i, 0);
if(counting.has(i)) counting.set(i, counting.get(i)+1)
while(counting.get(i) > max) max++
}
for(let [key, value] of counting) {
if(value === max) countArray.push(key)
}
return countArray.length === 1 ? countArray[0] : -1;
}