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







<< Previous Next >>

Code for Converting a Mixed Fraction to Improper Fraction in JavaScript



Fractional Numbers

Like we all know, fractional numbers can either be Proper (e.g. 2/5), Improper (e.g. 5/2), or Mixed (e.g. 21/2),


Mixed to Improper Fraction Code in JavaScript

Say we have the fraction 32/5 - which is a mixed fraction; we can convert this fraction to an improper fraction by following a number of steps:

Step 1:

Multiply the whole number (3), by the denominator (5)
         ⇒ 3 X 5 = 15

Step 2:

Add the result from Step 1 to the numerator (2)
         ⇒ 15 + 2 = 17

Step 3:

Our obtained improper fraction is our new numerator (17) divided by our denominator (5).

Create a new file; On Notepad++: File, New.
Call it MixedToImproper.html.
Type out the adjoining JavaScript code for converting mixed to improper fractions.


So!

Feel free to try out your own numerator, denominator and whole number.









<< Previous Next >>