Skip to content

Instantly share code, notes, and snippets.

@themarcba
Created August 15, 2019 17:34
Show Gist options
  • Save themarcba/3426f6effbf7aa07f82ec14618e8bb1d to your computer and use it in GitHub Desktop.
Save themarcba/3426f6effbf7aa07f82ec14618e8bb1d to your computer and use it in GitHub Desktop.
// Transforms a string to either upper or lowercase, depending which is dominant
// code => code
// coDe => code
// CoDE => CODE
// etc.
const transform = input => {
const lower = [...input].reduce((count, char) => {
return char == char.toLowerCase() ? count + 1 : count
}, 0)
return lower / input.length >= .5 ? input.toLowerCase() : input.toUpperCase()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment