Skip to content

Instantly share code, notes, and snippets.

@omzi
Last active November 17, 2020 09:01
Show Gist options
  • Save omzi/7cca83e6d94645f4cea52c1a4319de66 to your computer and use it in GitHub Desktop.
Save omzi/7cca83e6d94645f4cea52c1a4319de66 to your computer and use it in GitHub Desktop.
Returns a string with inversed cases
/**
* Returns a string with inversed cases
* @param {String} string The 'string' to inverse the cases of its characters
*/
const caseInverse = string => string.split('').map(letter => letter.toUpperCase() === letter ? letter.toLowerCase() : letter.toUpperCase()).join('');
module.exports = caseInverse;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment