15.2k views
5 votes
Write a program that prompts the user to input two POSITIVE numbers — a dividend (numerator) and a divisor (denominator). Your program should then divide the numerator by the denominator. Lastly, your program will add the quotient and the remainder together.

1 Answer

4 votes

function divide(num, den, rem) { //Numerator, Denomenator, Remainder

rem = Math.abs(num) % Math.abs(den)

return rem

}

console.log(divide(13, 5)) // logs '3'

Math.abs() is a function to make the integer a positive integer so that negative integers cant be divided

'rem' gets the remainder

User Carcaret
by
7.9k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.