We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3042af9 commit cba0b70Copy full SHA for cba0b70
live8/test81/문제3/황장현.js
@@ -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