Skip to content

Instantly share code, notes, and snippets.

View markanthonyuy's full-sized avatar
💭
I may be slow to respond.

Mark markanthonyuy

💭
I may be slow to respond.
View GitHub Profile
@markanthonyuy
markanthonyuy / fomatMoney.js
Created February 26, 2015 05:41
Format Money function
function formatMoney(amount, currency) {
var splitPoint = amount.toLocaleString().split('.'),
newFormat;
if(splitPoint.length > 1) {
newFormat = splitPoint[0] + '.' + (splitPoint[1].length == 1 ? splitPoint[1] + '0' : splitPoint[1]);
} else {
newFormat = splitPoint[0] + '.00';
}
if(currency) return currency + newFormat;
return newFormat;