Created
August 15, 2019 17:34
-
-
Save themarcba/3426f6effbf7aa07f82ec14618e8bb1d to your computer and use it in GitHub Desktop.
This file contains 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
// 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