-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3398 from edu2122/eduardo
Reto #0 - JavaScript
- Loading branch information
Showing
2 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/javascript/edu2122.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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") | ||
*/ | ||
|
||
// Solución: | ||
|
||
function transformToHackerLanguage(chain) { | ||
const languageHacker = { | ||
a: '4', | ||
b: 'I3', | ||
c: '[', | ||
d: ')', | ||
e: '3', | ||
mi: '3', | ||
f: '|=', | ||
g: '&', | ||
h: '#', | ||
i: '1', | ||
j: ',_l', | ||
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' | ||
}; | ||
|
||
let chainMinuscule = chain.toLowerCase(); | ||
chainMinuscule.split('').forEach((character) => { | ||
if (languageHacker[character]) { | ||
console.log(chainMinuscule); | ||
chainMinuscule = chainMinuscule.replace(character, languageHacker[character]); | ||
}; | ||
}); | ||
return (chainMinuscule); | ||
}; | ||
console.log(transformToHackerLanguage('1231')); |