I am creating an app that totals a grocery bill. I have successfully been able to total it, but am not able to format it with the $. I am doing everything in my server code. I am using the numeralJS dependency. I do not know how to insert the
var string = numeral(1000).format('$0,0.00');)
into my response.
Here is my server coding:
var DB_id='52b08c08e4b03c65ed00ddb3',
collectionName='grocerylist',
columnName='price';
try {
query = Collection.query(DB_id, collectionName);
var i, len, value, sum = 0;
for(i = 0,len = query.length; i < len; i++) {
value = parseFloat(query[columnName]);
if (value) {
sum +=value;
}
}
response.success({Total:sum}, "application/json");
} catch (e) {
response.success({message: e.message, code: e.code},
"application/json");
}
var string = numeral(1000).format('$0,0.00');)