Skip to content

Commit

Permalink
Reto #1 - javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian1192 committed Jan 2, 2023
1 parent 89ce2b3 commit 0162714
Showing 1 changed file with 53 additions and 0 deletions.
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);

0 comments on commit 0162714

Please sign in to comment.