
function solution(record) {
var nickNames = {};
record = record.filter((rec) => {
const [event, id, name] = rec.split(" ");
name && (nickNames[id] = name);
return event !== "Change";
});
return record.map((rec) =>
rec[0] === "E"
? `${nickNames[rec.split(" ")[1]]}님이 들어왔습니다.`
: `${nickNames[rec.split(" ")[1]]}님이 나갔습니다.`
);
}