I need to create a 2D array with the size specified in the input fields. And fill in the generated fields so that they rotate clockwise, starting from the lower right corner.

I managed to create a 2D array, but I do not know how to fill it. Any help is appreciated.
$("button").click(function() { var brr=parseInt($("#brr").val()); var brs=parseInt($("#brs").val()); for (i=1; i<=brs; i++) { for (j=1; j<=brr; j++) { $("#output").append("<div class='k'>o</div>"); } $("#output").append("<br/>"); } })
source share