Decode the Message LeetCode solution in JavaScript

1
var decodeMessage = function (key, message) {
2
let result = "";
3
key = Array.from(new Set(key.split(" ").join("")));
4
const hash = new Map();
5
const alpha = "abcdefghijklmnopqrstuvwxyz";
6

7
for (let i = 0; i < alpha.length; i++) {
8
hash.set(key[i], alpha[i]);
9
}
10

11
for (let chr of message) {
12
result += hash.get(chr) || " ";
13
}
14

15
return result;
16
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0