코드입니다. 피드백 부탁드립니다~
function solution(s) {
let answer;
let max = Number.MIN_SAFE_INTEGER;
const sH = new Map();
for (let val of s) {
sH.set(val, val.length);
}
for (let [key, val] of sH) {
if (max < val) {
max = val;
answer = key;
}
}
return answer;
}
let str = ['teacher', 'time', 'student', 'beautiful', 'good'];
console.log(solution(str));