I have a problem with my code . I want to make a program that generates random numbers and multiplies them by 50 then adds 30 to them then removes the remaining decimals.
I also want to show how these number are calculated by using <h1>
tags.
after the equal symbol I want to show the final number that is multiplied by 50 and added by 30 and the decimals are removed.
<html>
<head>
<meta charset="UTF-8"/>
<title>Random Numbers</title>
<script>
function start(){
var num1 = Math.random();
var num2 = Math.random();
var num3 = Math.random();
var num4 = Math.random();
var num5 = Math.random();
var num11 = num1.toFixed(3);
var num22 = num2.toFixed(3);
var num33 = num3.toFixed(3);
var num44 = num4.toFixed(3);
var num55 = num5.toFixed(3);
/*var num111 = (num11 * 50);
var num222 = (num22 * 50);
var num333 = (num33 * 50);
var num444 = (num44 * 50);
var num555 = (num55 * 50);
/* ----------------------------------------------
var num111 = (num11) += 30;
var num222 = (num22) += 30;
var num333 = (num33) += 30;
var num444 = (num44) += 30;
var num555 = (num55) += 30;*/
document.getElementById("show1").innerHTML=num11 + '×' + '50' + '+' + '30' + '=' + num11;
document.getElementById("show2").innerHTML=num22 + '×' + '50' + '+' + '30' + '=' + num22;
document.getElementById("show3").innerHTML=num33 + '×' + '50' + '+' + '30' + '=' + num33;
document.getElementById("show4").innerHTML=num44 + '×' + '50' + '+' + '30' + '=' + num44;
document.getElementById("show5").innerHTML=num55 + '×' + '50' + '+' + '30' + '=' + num55;
}
</script>
</head>
<body>
<button id="btn" onclick="start()">Press the button</button><br/>
<h1 id="show1"></h1>
<h1 id="show2"></h1>
<h1 id="show3"></h1>
<h1 id="show4"></h1>
<h1 id="show5"></h1>
</body>