Guest User

Untitled

a guest
Jul 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. function numberToBRL(numero) {
  2. var numero = numero.toFixed(2).split('.');
  3. numero[0] = "R$ " + numero[0].split(/(?=(?:...)*$)/).join('.');
  4. return numero.join(',');
  5. }
  6.  
  7. var x = numberToBRL(9999000.33);
  8. console.log(x);
  9.  
  10. var y = numberToBRL(100000);
  11. console.log(y);
  12.  
  13. var z = numberToBRL(10.50);
  14. console.log(z);
Add Comment
Please, Sign In to add comment