We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 485aa58 commit 1cd3d4bCopy full SHA for 1cd3d4b
bona1122/[week4]Hash/Open_chat.js
@@ -0,0 +1,18 @@
1
+function solution(record) {
2
+ const userInfo = {}
3
+ const result = []
4
+ const MESSAGES = {
5
+ Enter: "님이 들어왔습니다.",
6
+ Leave: "님이 나갔습니다.",
7
+ }
8
+
9
+ record.forEach((r) => {
10
+ const [action, id, name] = r.split(" ")
11
+ if (name) userInfo[id] = name
12
+ if (action !== "Change") {
13
+ result.push([id, MESSAGES[action]])
14
15
+ })
16
17
+ return result.map(([id, message]) => userInfo[id] + message)
18
+}
0 commit comments