JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" value="sports">
    <input type="checkbox" value="news">

JavaScript

var mysub = [];
    $("input[type=checkbox]").on( "click", function() {
        var topic = $(this).val();
        if ($(this).is(':checked')) {  
            alert("Subscribed to: " + topic);
            
        } else {
            alert("Unsubscribed from: " + topic);
        }
    } );