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 16b93e3 commit 4b3f8eeCopy full SHA for 4b3f8ee
oh-chaeyeon/4주차_해시/오픈채팅방.js
@@ -0,0 +1,22 @@
1
+function solution(record) {
2
+ const nicknames = {};
3
+ const result = [];
4
+
5
+ record.forEach((entry) => {
6
+ const [action, userId, nickname] = entry.split(" ");
7
+ if (action !== "Leave") {
8
+ nicknames[userId] = nickname;
9
+ }
10
+ });
11
12
13
+ const [action, userId] = entry.split(" ");
14
+ if (action === "Enter") {
15
+ result.push(`${nicknames[userId]}님이 들어왔습니다.`);
16
+ } else if (action === "Leave") {
17
+ result.push(`${nicknames[userId]}님이 나갔습니다.`);
18
19
20
21
+ return result;
22
+}
0 commit comments