Why does this happen when i run the code : <p>Hey guys it's just that when I run this code I get three alerts saying "You won!", "it's a tie!" and "you lost" randomly where there should only be one alert. This is a rock paper scissors game what part of the code is wrong I have tried but couldn't find it</p>

<pre><code>var userAnswer = prompt("Rock, Paper or Scissor");

var theEnemy;
var d = Math.floor(Math.random() * 10 + 1);
document.write(d);


if(d === 3 || d === 2 || d === 1){
 var theEnemy = "Paper"
    if(userAnswer = "Rock"){
    alert("You lost!");
    }
    if(userAnswer = "Paper"){
    alert("it's a tie!");
    }
    if(userAnswer = "Scissor"){
    alert("You won");
    }
}

if(d === 7 || d === 6 || d === 5 || d === 4){
    var theEnemy="Rock";
    if(userAnswer = "Rock"){
    alert("it's a tie!");
    }
    if(userAnswer = "Paper"){
    alert("YOu won!");
    }
    if(userAnswer = "Scissor"){
    alert("You lost!");
    }
}

if(d === 8 || d === 9 || d=== 10){
    var theEnemy="Scissor";
    if(userAnswer = "Rock"){
    alert("You lost!");
    }
    if(userAnswer = "Paper"){
    alert("You won!");
    }
    if(userAnswer = "Scissor"){
    alert("It's a tie");
    }
}
</code></pre>
