Created
January 21, 2020 18:14
-
-
Save magicznyleszek/308be8fd036afdbe2bfaa9827a8afdde to your computer and use it in GitHub Desktop.
This file contains hidden or 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
szyfruj = (string) => { | |
const pairs = { | |
A: 'Z', | |
Ą: 'Ź', | |
B: 'Ż', | |
C: 'A', | |
Ć: 'Ą', | |
D: 'B', | |
E: 'C', | |
Ę: 'Ć', | |
F: 'D', | |
G: 'E', | |
H: 'Ę', | |
I: 'F', | |
J: 'G', | |
K: 'H', | |
L: 'I', | |
Ł: 'J', | |
M: 'K', | |
N: 'L', | |
Ń: 'Ł', | |
O: 'M', | |
Ó: 'N', | |
P: 'Ń', | |
R: 'O', | |
S: 'Ó', | |
Ś: 'P', | |
T: 'R', | |
U: 'S', | |
W: 'Ś', | |
Y: 'T', | |
Z: 'U', | |
Ź: 'W', | |
Ż: 'Y' | |
}; | |
let output = ''; | |
const stringArr = string.split(''); | |
console.debug(stringArr); | |
stringArr.forEach((char) => { | |
if (pairs[char]) { | |
output += pairs[char]; | |
} else { | |
output += char; | |
} | |
}); | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment