Write a JavaScript function named findTen that reads two numbers from two text fields and then outputs to a div "True" if either one of them is 10 or both of them are 10 or if their sum is 10. Otherwise your function should output "False" to the div.
This is what I have so far, but it is not outputting correctly. Something is wrong with my else if statement:
<script>
function findTen() {
var a = document.getElementById("one").value;
var b = document.getElementById("two").value;
var doTheMath = a + b;
if ( a == 10 || b == 10) {
alert("true");
}
else if (doTheMath == 10 ) {
alert("true");
}
else {
alert(a b doTheMath);
}
document.getElementById("output").innerHTML = c;
}
</script>
Your problem is that it handles the inputs as Strings and not as integers. what you have to do is make the strings into integers by using the parseInt function