Created
January 29, 2019 21:49
-
-
Save ozscosta/258745aba90dd7e398a5241a26db64c0 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
const temperaturas = { | |
'c': { | |
'f': (val) => (val * 1.8 + 32), | |
'k': (val) => (val + 273.15), | |
}, | |
'f': { | |
'c': (val) => (val - 32) / 1.8, | |
'k': (val) => (val * 1.8) - 459.67, | |
}, | |
'k': { | |
'c': (val) => (val - 273.15), | |
'f': (val) => (val * 1.8) - 459.67, | |
} | |
} | |
const converter = (unities, val, base, to) => Number(unities[base][to](val)) | |
converter(temperaturas, 0, 'c', 'f') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment