How can we get a checkbox checked only if a dynamic value matches the checkbox value in one line without applying if condition. otherwise uncheck checkbox,.
var checkVal = 'red';
$('#black:input[value="'+checkVal+'"]').prop('checked', true);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="black" id="black" checked>
<label class="form-check-label" for="black">
Black
</label>
</div>