Skip to content

Commit

Permalink
Solución reto #1 - javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeToT committed Jan 2, 2023
1 parent d228e1b commit f6d368f
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/javascript/JorgeToT.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Escribe un programa que reciba un texto y transforme lenguaje natural a
* "lenguaje hacker" (conocido realmente como "leet" o "1337"). Este lenguaje
* se caracteriza por sustituir caracteres alfanuméricos.
* - Utiliza esta tabla (https://www.gamehouse.com/blog/leet-speak-cheat-sheet/)
* con el alfabeto y los números en "leet".
* (Usa la primera opción de cada transformación. Por ejemplo "4" para la "a")
*/
const vocabulary = {
a: "4",
b: "I3",
c: "[",
d: ")",
e: "3",
f: "|=",
g: "&",
h: "#",
i: "1",
j: ",_|",
k: ">|",
l: "1",
m: "/\\/\\",
n: "^/",
o: "0",
p: "|*",
q: "(_,)",
r: "I2",
s: "5",
t: "7",
u: "(_)",
v: "/",
w: "//",
x: "><",
y: "`j",
z: "2",
1: "L",
2: "R",
3: "E",
4: "A",
5: "S",
6: "b",
7: "T",
8: "B",
9: "g",
0: "o",
};

const hackerTranslate = (text) => {
let hackerText = "";
for (let i = 0; i < text.length; i++) {
vocabulary[text[i].toLowerCase()]
? (hackerText += vocabulary[text[i].toLowerCase()])
: (hackerText += text[i]);
}
console.log(`${text} => ${hackerText}`);
return;
};

hackerTranslate("Prueba de lenguaje hacker");

0 comments on commit f6d368f

Please sign in to comment.