Skip to content

Instantly share code, notes, and snippets.

@montanaflynn
Created April 18, 2018 19:12
Show Gist options
  • Save montanaflynn/05fd9c01208be3870c2f484448ba02ed to your computer and use it in GitHub Desktop.
Save montanaflynn/05fd9c01208be3870c2f484448ba02ed to your computer and use it in GitHub Desktop.
Division of integers while keeping the remainder
var a = 100
var b = 3
function divideWithRemainder(a, b){
return {
quotient: ~~(a / b),
remainder: a % b
};
}
console.log(divideWithRemainder(a, b));
// {
// quotient: 33,
// remainder: 1
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment