Skip to content

Instantly share code, notes, and snippets.

View Spazcool's full-sized avatar
:shipit:
Ubiquitous Mendacious Polyglottal

Doug Wright Spazcool

:shipit:
Ubiquitous Mendacious Polyglottal
View GitHub Profile
@Spazcool
Spazcool / stateToAbbr.js
Created May 7, 2020 23:33 — forked from calebgrove/stateToAbbr.js
Convert state name to abbreviation in JavaScript. There's some better solutions in the comments, so scroll down!
// There's some better solutions in the comments, so scroll down and see how other folks have improved this!
// USAGE:
// abbrState('ny', 'name');
// --> 'New York'
// abbrState('New York', 'abbr');
// --> 'NY'
function abbrState(input, to){