Javascript String formatMoney()

Description

Javascript String formatMoney()


exports.strContains = function(str, substr) {
    return str.indexOf(substr) > -1;
}

exports.strPluck = function(str, token) {
    return str.substr(str.lastIndexOf(token) + token.length + 1);
}

String.prototype.formatMoney = function() {
    return "$" + this.substr(0, this.length - 2) + "." + this.substr(this.length - 2);
}



PreviousNext

Related