Hello, I am trying to create a dice game and my method is changing the innerText of the selectors dice1 and dice2. (Keep in mind I’m new to javascript so it’s probably not the best way to do it but it is the only way I personally found so far.)
Now I also want to print the sum of the two dice together, but no matter how I try to do it I end up getting the literal answer, so two dice of 5 become 55 etc. What am I missing here?
Is it because I’m using innerText? Thanks for now, greatly appreciate any answer. and forgive my noobines.
function gameStarts() {
dice1.innerText = Math.floor(Math.random() * 6) + 1;
dice2.innerText = Math.floor(Math.random() * 6) + 1;
hideControls();
if (dice1.innerText + dice2.innerText == playerKnockoutNumber) {
console.log(“KNOCKOUT”)
result.innerText = “You lost”;
} else {
result.innerText = dice1.innerText + dice2.innerText;
}