JSFiddle - React, Tailwind, and code Playground

by Amar Nyayapati

JavaScript

var n=prompt("enter the size");
    for(i=0;i < n ; i++){
        for(j=0 ; j < n; j++){
  document.write('<input type="checkbox" id="chk_'+i+j+'" onclick="func(this)" />');
        }
        document.write("<br />");
    }
    function func(that){
      for(i=0;i < n ; i++){
        for(j=0 ; j < n; j++){
            if((that).checked == true){  
                document.getElementById('chk_'+i+j).checked=true                     
            }
            else{
                document.getElementById('chk_'+i+j).checked=false             
            }        
        }
      }
    }