Skip to content

Instantly share code, notes, and snippets.

@andrijac
Created January 15, 2020 10:51
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 andrijac/a1b41677286e6e041f3c40bd1b8da5b2 to your computer and use it in GitHub Desktop.
Save andrijac/a1b41677286e6e041f3c40bd1b8da5b2 to your computer and use it in GitHub Desktop.
var sum = function(x, y) {
let scale = 100;
return ((x*scale)+(y*scale))/scale;
}
sum(0.1, 0.2)
// => 0.3
//OR
parseFloat((0.1+0.2).toFixed(2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment