I have this simple script that counts how many array elements matches my input but it seems like every if statement returns false.
I have checked that both (array element and input value) are Strings. Just can't figure out why it returns false.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div>
<input type="text" id="searchType">
</div>
<p id="count"></p>
<script type="text/javascript">
var bloodTypes = ["A+", "O-", "AB+", "O+", "AB+", "AB+", "O-", "AB+", "0+", "AB+"];
var n = 0;
for (var i = 0; i < bloodTypes.length; i++) {
if (bloodTypes[i] == document.getElementById("searchType").value){
n++;
}
}
document.getElementById("count").innerHTML = n;
</script>
</body>
</html>
scriptwithin the document.