JSFiddle - React, Tailwind, and code Playground
HTML
<div id="quiz-questions">
<div class="question">
<p class="prompt">A typical weeknight dinner for you...</p>
<ul class="choices">
<li><input type="radio" name="q1" value="family"> consists of three different entrees, one for each picky palate. </li>
<li><input type="radio" name="q1" value="entertainer"> is anything but typical.</li>
<li><input type="radio" name="q1" value="baker"> often includes fresh-baked bread.</li>
<li><input type="radio" name="q1" value="griller"> is cooked outside whenever weather permits.</li>
<li><input type="radio" name="q1" value="couple"> is a team production: seared scallops with pan sauce by you and a composed salad by your spouse.</li>
</ul>
</div>
<div class="question">
<p class="prompt">People describe your cooking as...</p>
<ul class="choices">
<li><input type="radio" name="q2" value="baker"> Dr. Atkins’ downfall.</li>
<li><input type="radio" name="q2" value="couple"> half of a winning team.</li>
<li><input type="radio" name="q2" value="entertainer"> sophisticated and eclectic. </li>
<li><input type="radio" name="q2" value="family"> made with love.</li>
<li><input type="radio" name="q2" value="griller"> smokin'.</li>
</ul>
</div>
<div class="question">
<p class="prompt">What do you bring for a potluck dinner?</p>
<ul class="choices">
<li><input type="radio" name="q3" value="griller"> Marinated kebabs ready to throw on the grill.</li>
<li><input type="radio" name="q3" value="family"> A pot of chili that everyone can customize as they like with toppings.</li>
<li><input type="radio" name="q3" value="entertainer"> Your signature cocktail.</li>
<li><input type="radio"...
CSS
#quiz-questions {
width: 700px;
}
#quiz-questions .question {
margin: 40px;
}
#quiz-questions .question p.prompt {
font-weight: bold;
margin-bottom: 10px;
color: #F08012;
font-size: 16px;
}
#quiz-questions .question li {
margin-bottom: 5px;
font-size: 14px;
}
JavaScript
$(document).on('click','#calcbtn',function(){
var values = ['family','entertainer','baker','griller','couple'];
var result = [];
$.each( values, function( i, value){
result.push({
value: value,
sum: $('input:radio[value='+value+']:checked').length
});
});
result.sort( function( a, b ){
if( a.sum < b.sum ) return +1;
if( a.sum > b.sum ) return -1;
return 0;
});
console.log(result);
alert('You are a '+result[0].value );
});