I tried to compare a simple code where if user click on the button, then the output will display appropriate answer but I can't seem to find any correct way to do it.
<!DOCTYPE html>
<html>
<body>
<p>Gender</p>
<label><input type="radio" name="gender" id="male" value="Male">Male</label>
<label><input type="radio" name="gender" id="male" value="Female">Female</label>
<br>
<br>
<button onclick="myFunction()">Try it</button>
<p id="demo">
<script>
function myFunction() {
var x = document.getElementById("demo").value;
var m = document.getElementById("male").value;
var f = document.getElementById("female").value;
if(x === m)
x.innerHTML = "You are male.";
else if(x === f)
x.innerHTML = "You are female.";
}
</script>
</body>
</html>