Skip to content

Commit cba0b70

Browse files
committed
81차 3번 문제풀이
1 parent 3042af9 commit cba0b70

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

live8/test81/문제3/황장현.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
function solution(record) {
2+
const userInfo = {};
3+
const action = [];
4+
const stateMapping = {
5+
Enter: '님이 들어왔습니다.',
6+
Leave: '님이 나갔습니다.',
7+
};
8+
9+
record.forEach((v) => {
10+
const [state, id, nick] = v.split(' ');
11+
12+
if (state !== 'Change') {
13+
action.push([state, id]);
14+
}
15+
16+
if (nick) {
17+
userInfo[id] = nick;
18+
}
19+
});
20+
console.log(userInfo);
21+
22+
return action.map(([state, uid]) => {
23+
return `${userInfo[uid]}${stateMapping[state]}`;
24+
});
25+
}
26+
console.log(
27+
solution([
28+
'Enter uid1234 Muzi',
29+
'Enter uid4567 Prodo',
30+
'Leave uid1234',
31+
'Enter uid1234 Prodo',
32+
'Change uid4567 Ryan',
33+
])
34+
);
35+
36+
const obj = {};
37+
obj['asdf'] = '1';
38+
console.log(obj.asdf);

0 commit comments

Comments
 (0)