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
1 parent
d74dbfd
commit 55c3766
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
Retos/Reto #15 - AUREBESH [Fácil]/javascript/BRivasTorres.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,63 @@ | ||
const aurebeshAlphabet = { | ||
a: "aurek", | ||
b: "besh", | ||
c: "cresh", | ||
d: "dorn", | ||
e: "esk", | ||
f: "forn", | ||
g: "grek", | ||
h: "herf", | ||
i: "isk", | ||
j: "jenth", | ||
k: "krill", | ||
l: "leth", | ||
m: "merm", | ||
n: "nern", | ||
o: "osk", | ||
p: "peth", | ||
q: "qek", | ||
r: "resh", | ||
s: "senth", | ||
t: "trill", | ||
u: "usk", | ||
v: "vev", | ||
w: "wesk", | ||
x: "xesh", | ||
y: "yirt", | ||
z: "zerek", | ||
ae: "enth", | ||
eo: "onith", | ||
kh: "krenth", | ||
ng: "nen", | ||
oo: "orenth", | ||
sh: "sen", | ||
th: "thesh", | ||
}; | ||
|
||
const convertLanguaje = (languaje, s) => { | ||
let res = "" | ||
|
||
if(languaje.toLowerCase() === "aurebesh") { | ||
for(let i = 0; i < s.length; i++) { | ||
isLetter = s[i] in aurebeshAlphabet | ||
let val = aurebeshAlphabet[s[i]] | ||
isLetter ? res += val : res += s[i] | ||
res += val + " " | ||
} | ||
} else { | ||
let arr = s.split(" ") | ||
for(let i = 0; i < arr.length; i++) { | ||
for(const key in aurebeshAlphabet) { | ||
if(aurebeshAlphabet[key] === arr[i]) { | ||
res += key | ||
} | ||
} | ||
} | ||
} | ||
return res.trim() | ||
}; | ||
|
||
|
||
console.log(convertLanguaje("aurebesh", "hola")); | ||
console.log(convertLanguaje("aurebesh", "buenos dias")); | ||
console.log(convertLanguaje("español", "herf osk leth aurek")); |