Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var formato = { minimumFractionDigits: 2 , style: 'currency', currency: 'BRL' }
- $("#totalEntrada").append($entrada.toLocaleString('pt-BR', formato));
- $("#totalSaida").append($saida.toLocaleString('pt-BR', formato));
- $("#totalGeral").append($total.toLocaleString('pt-BR', formato));
- toLocaleString
- var numero = 1.6;
- var dinheiro = numero.toLocaleString("pt-BR", { minimumFractionDigits: 2 , style: 'currency', currency: 'BRL' });
- function toLocaleStringSupportsLocales() {
- var number = 0;
- try {
- number.toLocaleString('i');
- } catch (e) {
- return eā.name === 'RangeError';
- }
- return false;
- }
- if(!toLocaleStringSupportsLocales()){
- Number.prototype.toLocaleString = function(lingua, opcoes) {
- var numero = this.toFixed(2).replace(".", ",");
- if(!opcoes)
- return numero;
- if(opcoes.style == "currency")
- return "R$ " + numero;
- }
- }
- $("#totalEntrada").append("R$ " + $entrada);
- $("#totalSaida").append("R$ " + $saida)
- $("#totalGeral").append("R$ " + $total);
- $("#totalEntrada").append("R$ " + Number($entrada).toFixed(2));
- $("#totalSaida").append("R$ " + Number($saida).toFixed(2));
- $("#totalGeral").append("R$ " + Number($total).toFixed(2));
- const centsToMoney = cents => 'R$' + (cents / 100).toFixed(2).replace('.', ',').split('').reverse().map((v, i) => i > 5 && (i + 6) % 3 === 0 ? `${v}.` : v).reverse().join('')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement