Q:

Write a JavaScript program to check whether a given fraction is proper or not

0

Write a JavaScript program to check whether a given fraction is proper or not.

Note: There are two types of common fractions, proper or improper. When the numerator and the denominator are both positive, the fraction is called proper if the numerator is less than the denominator, and improper otherwise

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function proper_improper_test(num) {
  return Math.abs(num[0] / num[1]) < 1
    ? "Proper fraction."
    : "Improper fraction.";
}
console.log(proper_improper_test([12, 300]));
console.log(proper_improper_test([2, 4]));
console.log(proper_improper_test([103, 3]));
console.log(proper_improper_test([104, 2]));
console.log(proper_improper_test([5, 40]));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now