I have a form/questionnaire where the user must choose various options in HTML. Javascript will then add up all the options; there are more forms that will be added up to create a grand total. I know that I need to use parseInt and various if statements: if option 1 is selected, return value if option 2 is selected, return value and so on..
HTML:
<input type="radio" name="age" id= "age1" value="0" checked> 1-25<br>
<input type="radio" name="age" id= "age2" value="5"> 26-40<br>
<input type="radio" name="age" id= "age3" value="8"> 41-60<br>
<input type="radio" name="age" id= "age4" value="10"> 60+<br>
Javascript:
calculateAge () {
var age = parseInt (document.getElementById('age1').value)
if (age = checked) return age;
console.log('age')
}