Skip to content

Instantly share code, notes, and snippets.

@Santiael
Last active August 18, 2025 13:21
Show Gist options
  • Save Santiael/4c6bec1781d5ed0c15d450ffc39fb291 to your computer and use it in GitHub Desktop.
Save Santiael/4c6bec1781d5ed0c15d450ffc39fb291 to your computer and use it in GitHub Desktop.
invertPhrase = (phrase) => {
const characters = [...`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!,.()"`];
const invertedCharacters = [...`ɐqɔpǝⅎƃɥᴉɾʞʅɯuodbɹsʇnʌʍxʎz∀ꓭϽᗡƎᖵ⅁HIᒋꓘ⅂ꟽNOԀꝹꓤSꓕՈɅϺX⅄Z0⇂↊↋ߤ59𝘓86¿¡ʻ.)(﮼`];
const phraseArray = [...phrase];
const invertedPhrase = phraseArray.reduce((acc, cur) => {
const index = characters.indexOf(cur);
if(index < 0) return cur + acc;
return invertedCharacters[index] + acc;
}, "");
return invertedPhrase;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment