Fill out a spiral matrix
Seems mostly solid to me. I just have two small remarks:




const spiralMatrix = (n) =&gt; {



I'm not a big fan of using the arrow syntax here. The arrow syntax is (mostly) used for inline functions. For a "top level" function I'd prefer a normal, more readable (and hoisted) function declaration:

function spiralMatrix(n) {


The only disadvantage I see is that const prevents accidental overwriting, which I don't see as an serious problem in this case.



And .fill(0) during initialization of the arrays is unnecessary.