- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing

- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM

- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers

- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources

# Converting a proper fraction to mixed fraction - JavaScript

## Proper Fraction

A proper fraction is the one that exists in the p/q form (both p and q being natural numbers)

## Mixed Fraction

Suppose we divide the numerator of a fraction (say a) with its denominator (say b), to get quotient q and remainder r.

The mixed fraction form for fraction (a/b) will be −

qrb

And it is pronounced as "q wholes and r by b”.

We are required to write a JavaScript function that takes in an array of exactly two numbers representing a proper fraction and our function should return an array with three numbers representing its mixed form

## Example

Following is the code −

const arr = [43, 13]; const properToMixed = arr => { const quotient = Math.floor(arr[0] / arr[1]); const remainder = arr[0] % arr[1]; if(remainder === 0){ return [quotient]; }else{ return [quotient, remainder, arr[1]]; }; }; console.log(properToMixed(arr));

## Output

Following is the output in the console −

[ 3, 4, 13 ]

- Related Articles
- How To Convert Mixed fraction into Improper Fraction
- How to change mixed fraction into improper fraction.
- Explain mixed fraction
- What is a mixed fraction?
- How to convert the mixed fraction into an improper fraction?
- How can we change an improper fraction into a mixed fraction?
- What is the meaning of Mixed Fraction?
- How to change $\frac{30}{2}$ in mixed fraction?
- Convert the following into a mixed fraction:$\frac{11}{4}$
- Convert the following into mixed fraction $\frac{17}{5}$.
- Evaluate the following and express the answer as a mixed fraction.
- Write the mixed fraction \( 7 \frac{3}{40} \) as a decimal number.
- C program to convert decimal fraction to binary fraction
- Express as mixed fraction:$\frac{17}{7}$ and $\frac{28}{5}$
- How to convert a decimal into a fraction and a fraction into a decimal?

Advertisements