Skip to content

Commit

Permalink
refactor: format function to toLocaleString (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
falcao-g authored Jul 9, 2024
1 parent b2ea9f7 commit cacc8ad
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/utils/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,11 @@ function specialArg(string, total) {
* @returns {string}
*/
function format(falcoins) {
if (parseInt(falcoins) < 0) {
falcoins = falcoins.toString();
pop = falcoins.slice(1);
} else {
pop = falcoins.toString();
if (falcoins < 0) {
falcoins = Math.abs(falcoins);
}
pop_reverse = pop.split('').reverse().join('');
pop_2 = '';
for (c in pop_reverse) {
if (c / 3 == parseInt(c / 3) && c / 3 != 0) {
pop_2 += '.';
pop_2 += pop_reverse[c];
} else {
pop_2 += pop_reverse[c];
}
}
return pop_2.split('').reverse().join('');

return falcoins.toLocaleString('pt-BR');
}

/**
Expand Down

0 comments on commit cacc8ad

Please sign in to comment.