im a beginner in javascript and i dont know what's wrong with my codes, its a guessing game and i wanted the output to be higher, lower and equals. the output of my codes are always equals.. i dont know what is wrong. help pls. thanks
Code:
<html>
<head>
<script language="javascript">
function textNum(){
var r = Math.floor(Math.random()*10);
var A = document.getElementById('enterno').value;
var higher = r>A;
var lower = r<A;
var equal = r=A;
if ( r > A)
{
document.getElementById('rem').value = "higher";
}
else if (r < A)
{
document.getElementById('rem').value = "lower";
}
else (r = A)
{
document.getElementById('rem').value = "equal";
}
}
function checkbrowser() {
var x = navigator
alert("CodeName=" + x.appCodeName + '\n' + "Name=" + x.appName + '\n' + "Version=" + x.appVersion)
}
</script>
</head>
<body>
<table width="364" border="1">
<tr>
<td colspan ="2">Guess the Number</td>
</tr>
<tr>
<td>Enter a Number from 1 - 10:</td>
<td>
<input type="text" id="enterno" name="enterno"/> </td>
</tr>
<tr>
<td>Check Remarks Here:</td>
<td>
<input type="text" id="rem" name="rem" readonly="readonly"/>
</td>
</tr>
<tr>
<td colspan="2"> <form>
<input type="button" value="Test The Number" onclick = "textNum()"/>
<input type="button" value="Try Again" onclick = "try()"/>
<input type="button" value="Check Browser" onclick = "checkbrowser()"/>
</form></td>
</tr>
</table>
</body>
</html>
Comment