Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format Currency, Math.round(); #146

Open
okontg opened this issue Sep 1, 2024 · 2 comments
Open

Format Currency, Math.round(); #146

okontg opened this issue Sep 1, 2024 · 2 comments

Comments

@okontg
Copy link

okontg commented Sep 1, 2024

please using the Math.round(), rounds my to 21.00, and 11.00, instead of 20.95, and 10.90 from the example.
i don't know if is from my browser or there's an error in my code.

export function formatCurency(priceCent){
return( Math.round(priceCent / 100)).toFixed(2)
}

@LastShinobu
Copy link

return (Math.round(priceCents) / 100).toFixed(2);

@okontg
Copy link
Author

okontg commented Sep 4, 2024

Thanks bro, i later figure it out, i needed to round the priceCents only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants