get all selected checkbox value and display them wanted to separate each element in the array into new line
$('#generate').on('click', function() {
var array = [];
$("input:checked").each(function() {
array.push($(this).val());
});
$("#selectedSubject").text(array+'<br>');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
array.push($(this).val() + '<br>');$("#selectedSubject").text(array.join());("#selectedSubject").text(array.join('<br>'));