I want to Round off the decimal place of a number to the next multiple of 5 I have tried this but it's not working for decimal places
const roundOff = (num) =>{
let temp = parseFloat(num.toFixed(2)) // to make it 2 place decimal
return Math.ceil(temp / 5) * 5
}
roundOff(54.5678) // should give 54.60
roundOff(43.738) // should give 43.75
roundOff(89.982) // should give 90.00
roundOff(80.034) // should give 80.05
const roundOff = (num) =>{
return (Math.ceil(num * 20) / 20).toFixed(2)
}
console.log(roundOff(54.5678)) // should give 54.60
console.log(roundOff(43.738)) // should give 43.75
console.log(roundOff(89.982)) // should give 90.00
console.log(roundOff(80.034))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With