Created
December 24, 2020 21:55
-
-
Save ricealexander/471761607828e0b7d5febfa717465e9a to your computer and use it in GitHub Desktop.
When you receive a list of sponsors in ALL CAPS
This file contains hidden or 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
const sponsors = [ | |
'BARNES JEWISH HOSPITAL', | |
'BARNES JEWISH WEST COUNTY HOSPITAL', | |
'BELLEVILLE NEWS DEMOCRAT', | |
'BESPOKE APPAREL', | |
'BETTER BUSINESS BUREAU', | |
'BIG BOW EVENTS', | |
'BIG O LIQUEUR', | |
] | |
const capitalize = string => { | |
if (string.length < 2) return string.toUpperCase() | |
return string[0].toUpperCase() + string.slice(1).toLowerCase() | |
} | |
const cleanSponsors = sponsors.map(name => { | |
const words = name.split(' ') | |
return words.map(word => { | |
if (word === word.toUpperCase()) { | |
return capitalize(word) | |
} | |
return word | |
}).join(' ') | |
}) | |
copy(cleanSponsors) | |
// remember to manually review the results. | |
// some words, such as "of" and "the" may need to be lowercased | |
// others, such as "LLC" may need to be caps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment