const getSquareFormations = (squareCount) => { const squareFormations = [] for(let row = 1; row < (squareCount+1); row++) { for(let column = 1; column < (squareCount+1); column++) { if (row*column >= squareCount) //the formation can fit the squares { if (row === squareCount && column>1) //all squares are in one column { continue } else if (column === squareCount && row>1) //all squares are in one row { continue } const formation = { rows: row, columns: column, size: row*column } squareFormations.push(formation) } } } return squareFormations }