Skip to content

Instantly share code, notes, and snippets.

@magicznyleszek
Created January 21, 2020 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magicznyleszek/308be8fd036afdbe2bfaa9827a8afdde to your computer and use it in GitHub Desktop.
Save magicznyleszek/308be8fd036afdbe2bfaa9827a8afdde to your computer and use it in GitHub Desktop.
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