usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< Previous Next >>

Code for Dividing Fractions in JavaScript



Method of Dividing Fractions

Division is the inverse operation of multiplication; That is exactly what we'll do with for fractions.
Invert the fractions that come after a division sign, as well change the division sign to multiplication, and then follow through with multiplication.


Algorithm Steps to Divide Fractions in JavaScript

Say we are to simplify
                  21/8 ÷ 7/2;

Inverting this will yield
                  21/8 ÷ 7/2;

Then we can go ahead and multiply.


Create 2 new files; On Notepad++: File, New.
Call them DivideFraction.html and DivideFraction.js;
Type out the adjoining JavaScript code for dividing fractions.


Note: The bulk of the divide_fraction.js code is a copy of that for multiplying fractions.


So!

Feel free to try out your own set of numerators and denominators for fractional division.









<< Previous Next >>