Javascript Number convertToFloat()

Description

Javascript Number convertToFloat()


/*//from   w  w w  .j  av a2 s .  com
    3. Extend number type to have a 'float()' function that will convert any given 'integer' value to its float equivalent. (a no such as 5 should become 5.00) The function should only return that value and should not affect the actual number's value.
*/

Number.prototype.convertToFloat = function(){
    return this.toFixed(2);
}



PreviousNext

Related