1
I came across the following syntax error in javascript/jquery
Uncaught Syntaxerror: Unexpected number
and I’m using the plugin Number.prototype.formatMoney might have something related?
Plugin
Number.prototype.formatMoney = function(c, d, t){
var n = this,
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = typeof d == "undefined" ? "." : d,
t = typeof t == "undefined" ? "," : t,
s = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
Calling method
$("#dados #total").html("R$ "+(parseFloat(total)).formatMoney(2, ',', '.'));
Know how to solve?
Dude, I created a fiddle (http://jsfiddle.net/1dqhqu4s/) with its code and it works fine. It is very likely that the problem is in another location, could include some more of your code?
– Edgar Muniz Berlinck
@Edgarmunizberlinck the code is too big, I’ll see some likely snippets that might be wrong, but you know specifically why this error happens
Uncaught SyntaxError: Unexpected number
? if you can also give some example of occasion when this mistake happens, thank you :)– Silvio Andorinha
Dude, this is really syntax error. See the EDIT of my answer. If it doesn’t help yell there.
– Edgar Muniz Berlinck