JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>

JavaScript

var list = $('input[type="checkbox"]');
var number = 5;

if(number<list.length)
for(var i=0;i<number;i++){
 	$(list[i]).attr('checked',true);   
}