Here's the code below:
let moneyToReturn = 0.5
let note = 0.01
let sum = 0
while(moneyToReturn-note>=0){
moneyToReturn = ((moneyToReturn*10 - note*10)/10).toFixed(2)
sum = ((sum*10 + note*10)/10).toFixed(2)
// moneyToReturn -= note
// sum += note
console.log(sum)
}
To make sure that I'm not logging my sum with crazy decimal places on each computation I need to write this code.
((x * 10 + y * 10)/10).toFixed(2)
What is the better/shorter way of doing that?