You have missed "==". Please open the below link (
Tryit Editor v3.3[
^]) and copy the code to verify.
<!DOCTYPE html>
<html>
<body>
<script>
function checkAge(radio){
alert(radio.value);
var age = "";
if(radio.value=="child"){
age = "child";
}
else if (radio.value=="adult") {
age = "adult";
}
else {
age = "senior";
}
alert(age);
}
</script>
<form action="">
<input type="radio" name="gender" onclick="checkAge(this)" value="child"> child<br>
<input type="radio" name="gender" onclick="checkAge(this)" value="adult"> adult<br>
<input type="radio" name="gender" onclick="checkAge(this)" value="senior"> senior
</form>
<p> * The selected value will be shown in the alert box upon select. </p>
</body>
</html>
Thank you.