forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
Retos/Reto #1 - EL LENGUAJE HACKER [Fácil]/javascript/Arian1192.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,53 @@ | ||
"use strict"; | ||
const mapper = { | ||
a: "4", | ||
b: "l3", | ||
c: "[", | ||
d: ")", | ||
e: "3", | ||
f: "|=", | ||
g: "&", | ||
h: "#", | ||
i: "1", | ||
j: ",_l", | ||
k: ">|", | ||
l: "1", | ||
m: "/\\/\\", | ||
n: "^/", | ||
o: "0", | ||
p: "|*", | ||
q: "(_,)", | ||
r: "l2", | ||
s: "5", | ||
t: "7", | ||
u: "|_|", | ||
v: "\\/", | ||
w: "\\/\\/", | ||
x: "><", | ||
y: "`/", | ||
z: "2" | ||
}; | ||
// crear una funcion que tranforme una palabra en un array de valores | ||
const frase = 'mouredew'; | ||
const transformString = (frase) => { | ||
// paso la frase a minusculas | ||
frase = frase.toLowerCase(); | ||
// la convierto en un array de caracteres separado por comas | ||
const arr = frase.split(''); | ||
// creo un array donde voy a pushear el resultado | ||
let newArr = []; | ||
// recorro el array | ||
arr.map((letra) => { | ||
if (letra in mapper) { | ||
newArr.push(mapper[letra]); | ||
} | ||
else if (letra === ' ') { | ||
newArr.push(letra); | ||
} | ||
else { | ||
newArr.push(letra); | ||
} | ||
}); | ||
console.log(newArr.join('')); | ||
}; | ||
transformString(frase); |