You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/js/Math/Calculate the divisor and m...

12 lines
317 B
JavaScript

function div_mod(a, b)
{
if (b <= 0)
throw new Error("b cannot be zero. Undefined.");
if (isInt(a) && !isInt(b))
throw new Error("A or B are not integers.");
return [Math.floor(a / b), a % b];
}
function isInt(n) {
return n % 1 === 0;
}
console.log(div_mod(17, 4));