Number.prototype.number_with_delimiter = function(delimiter, separator) {
var number = this + '';
separator = separator || '.';
delimiter = delimiter || ',';
var split = number.split(separator);
split[0] = split[0].replace(
/(\d)(?=(\d\d\d)+(?!\d))/g,
'$1' + delimiter
);
return split.join(separator);
};
A display helper for numbers to include commas or periods similar to the Rails method found here:
http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_delimiter
http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_delimiter
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.