Calculates a:b to string form - Node.js String

Node.js examples for String:Format

Description

Calculates a:b to string form

Demo Code

Math.ratio = function ( a, b ) {
    a = Number( a );/*from   w  w w  .j  a  v  a 2  s .  c o m*/
    b = Number( b );

    var gcd = this.gcd( a, b );
    return ( a / gcd ) + ':' + ( b / gcd );
};

Related Tutorials