JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" value="one" name="box">one</input>
<input type="checkbox" value="two" name="box">two</input>
<input type="checkbox" value="three" name="box">three</input>
<input type="checkbox" value="four" name="box">four</input>
<button id="run">Run</button>

JavaScript

var choices = [];
$("#run").click(function(){
    choices = [];
    $( "input:checkbox:checked" ).each(function( i,value ) {
        choices.push($(this).attr('value')); 
    });
    var randomItem = Math.ceil(Math.random()*choices.length)-1;
    alert(choices[randomItem]);
});