SuperSimpleDev / javascript-course

708 stars 568 forks source link

Format Currency, Math.round(); #146

Open okontg opened 1 week ago

okontg commented 1 week ago

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 commented 1 week ago

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

okontg commented 1 week ago

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