<button onclick = "p1Heal()" id="heal">Heal</button>
<div id="p1Health">100</div>
Actually I want to increment the health by some random number between 1-5 so I used the Math.random but it is concatenating the string and the number
I tried doing this:
let p1HealthDiv = document.getElementById('p1Health')
function p1Heal(){
const p1Heall = Math.floor(Math.random()*5);
p1HealthDiv.innerHTML += `${Number(p1Heall)}`
}
but instead it is concatenating with the string i.e 100 the output I am getting is: if the health is 91 it adding (0/1/2/3/4) in the div and displaying as 912I actually want it to increase it to + (any number between 0 and 4) like: 94
Might be a stupid question, just a student and new to learning this language and, hoping to get a positive reply from my senior fellows Thank you.