This is probably very simple but I have two values with IDs of ‘x’ and ‘y’. I am attempting to get the value of ‘x’ as a percentage of ‘y’ and output that percentage to a third ID ‘z’.
How can I get the result of the calculation and send it to a text element with ‘z’ ID?
const xValue = document.getElementById('x');
const yValue = document.getElementById('y');
var zPercentage = Math.round(((xValue / yValue) * 100)) + "%";
<body>
<div id="x">25</div>
<div id="y">200</div>
<div id="z">percentage</div>
</body>
1