When I run this script on my localhost instead of checking for the value, it corrects the pin instead.
This is my first time using JavaScript but I have run if else statements identical to this one in multiple other languages with no issue. I just don’t see where the issue is coming from in the code.
When I press submit, the pin changes to “1234” and it displays the “Correct” message regardless of what I have typed in or if I just leave it as
function PINCheck() {
var result = document.getElementById("ErrorMessage")
var pin = document.getElementById("Pin")
if (pin.value = "1234") {
result.innerText = "Correct"
} else if (pin.value != "1234") {
pin.innerText = "******"
result.innerText = "Incorrect PIN"
}
}
<container class="container">
<label for="Pin">PIN</label><br>
<input type="text" id="Pin" name="Pin" value="******"><br>
<button onclick="PINCheck()">SUBMIT</button>
<p id="ErrorMessage">---</p>
</container>