I am working on code for a site am trying to take an input and based on the input display a specific message. Whenever I type in a number however it is being set to the first if result. Any help would be great, thanks
<form name="testsDone">
How many of your tests have you taken? <input type ="text" id="tookTests" /><br />
</form>
<script>
function testCheck(){
var a = parseFloat(document.getElementById("tookTests").value);
var b = a;
var c;
if (b = 2 ) {
c = "Yes you can! You've earned it.";
} else if (b = 1) {
c = "You need to keep studying then";
}
else if (b > 2 ) {
c = "That's more tests than you're supposed to have";
}else {
c = "Why are you on here? You need to study.";
}
document.getElementById("change").innerHTML = c;
}
</script>
<button onclick="testCheck()">Check and See</button>
<p> Can you go to sleep?</p>
<p id="change"></p>