Skip to content

Commit 1cd3d4b

Browse files
committed
Open chat / 심화
1 parent 485aa58 commit 1cd3d4b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

bona1122/[week4]Hash/Open_chat.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)