I have come across this problem in a calculation I do in my code, where the divisor is 0 if the divident is 0 too. In my code I return 0 for that case. I am wondering, while div
This is what I'd do:
function div(a, b) { if(b === 0 && a !== 0) { return undefined; } if(b === 0 && a === 0) { return Math.random; } return a/b; }