Skip to content

Instantly share code, notes, and snippets.

@01Clarian
Created December 16, 2019 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 01Clarian/1952ed1f945fcc16b6d88f3fb8f5f241 to your computer and use it in GitHub Desktop.
Save 01Clarian/1952ed1f945fcc16b6d88f3fb8f5f241 to your computer and use it in GitHub Desktop.
Final Conversion Kelvin Currying Example Code
//grabbing the dom ids:
const convertKelvin = document.querySelector('#convertKelvin')
const results = document.querySelector('#results')
const kelvinNumber = document.getElementById('kelvinNumber')
convertKelvin.onclick = () => {
console.log('test')
//convertKelvinReg(300)
const currier = convertKelvinCurried(kelvinNumber.value)()
currier
}
// non curried function
const convertKelvinReg = (kelvin, formula) => {
formula = (Math.round((kelvin - 273.15) * 9 / 5) + 32)
return results.innerHTML = formula
}
//curried function
const convertKelvinCurried = (kelvin) => (formula) => {
formula = (Math.round((kelvin - 273.15) * 9 / 5) + 32)
return results.innerHTML = formula
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment