링크: https://programmers.co.kr/learn/courses/30/lessons/42888
function solution(record) {
const action = [];
const userInfo = {};
const states = {
"Enter": "님이 들어왔습니다.",
"Leave": "님이 나갔습니다.",
};
record.forEach((item) => {
const [state, uid, name] = item.split(" ");
if (state !== "Change") {
action.push([state, uid]);
}
if (name) {
userInfo[uid] = name;
}
})
return action.map((item) => `${userInfo[item[1]]}${states[item[0]]}`);
}