function solution(record) {
var answer = [];
var idName = new Map();
var cmds = []
for (const reco of record)
{
var data = reco.split(' ');
var cmd = data[0];
var id = data[1];
if (cmd !== 'Change')
{
cmds.push([cmd,id]);
}
if (data.length == 3)
{
idName.set(id, data[2]);
}
}
for (const e of cmds)
{
if (e[0] === 'Enter'){
answer.push(`${idName.get(e[1])}๋์ด ๋ค์ด์์ต๋๋ค.`);
}
else{
answer.push(`${idName.get(e[1])}๋์ด ๋๊ฐ์ต๋๋ค.`);
}
}
return answer;
}
'๐ฏ CodingTest > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Programmers] (Javascript) ๊ดํธ ๋ณํ (0) | 2022.04.25 |
---|---|
[Programmers] (Javascript) ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ (0) | 2022.04.21 |
[Programmers] (Javascript) ๋ฌธ์์ด ์์ถ (0) | 2022.04.21 |
[Programmers] (Javascript) [1์ฐจ] ๋น๋ฐ์ง๋ (0) | 2022.04.21 |
[Programmers] (Javascript) ์คํจ์จ (0) | 2022.04.21 |