I am trying to write a quick script that will update a spans text every 1 second to add a random amount of money to the amount. This issue I am facing is the randomNumber variable returns lots of decimal places and doesn't seem to be doing what I want. I just want to add a random number of £0.03 pence to £6.43 added on to the existing number. Is there a way to stop it outputting decimal numbers like 10.333333333333333333 and so on? and possibly just make it more robust and output the correct value.
var number = 0;
setInterval(function(){
var randomNumber = Math.floor(Math.random() * (6.43 - 0.3 + 1)) + 0.3;
number += randomNumber;
document.getElementsByClassName("currency")[0].textContent = "£" + number;
}, 1000);