-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemojiArms.js
65 lines (62 loc) · 1.47 KB
/
emojiArms.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*Output a bracket emoji with both arms.
You will be given its face and its left arm. A simple bracket emoji will look like this:
<-('/\')->
The right arm is a mirror image of the left arm:
- reverse the order of the characters in the left arm
- replace the following characters with the mirrored version:
'<' and '>', '/' and '\', '[' and ']', '{' and '}', '(' and ')'
Example:
If face is (~n~) and left arm is >-, output
>-(~n~)-<
Entrée
Line 1: A string face for the face of the emoji
Line 2: A string left arm for the left arm
Sortie
The bracket emoji
Contraintes
face and arm contain only ASCII characters.
Exemple
Entrée
(~n~)
|-
Sortie
|-(~n~)-|*/
function emojiArms(emoji, arm) {
return (
arm +
emoji +
arm
.split("")
.reverse()
.map((char) => {
switch (char) {
case "<":
return ">";
case ">":
return "<";
case "/":
return "\\";
case "\\":
return "/";
case "[":
return "]";
case "]":
return "[";
case "{":
return "}";
case "}":
return "{";
case "(":
return ")";
case ")":
return "(";
default:
return char;
}
})
.join("")
);
}
console.log(emojiArms("(~n~)", "|-)")); // |-(~n~)-|
console.log(emojiArms("(-.-)", "<-")); // <-(-.-)->
console.log(emojiArms("(-_-)", "(-_-)")); // (-_-)(-_-)