# [JavaScript (Node.js)], 71 bytes

<!-- language-all: lang-javascript -->

    n=>[...(m=Array(n)).keys()].map(a=>[...m.keys()].map(b=>-~a>++b?-~a:b))

[Try it online!][TIO-kpr8mk8r]

[JavaScript (Node.js)]: https://nodejs.org
[TIO-kpr8mk8r]: https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/P1i5aT09PI9fWsagosVIjT1NTLzu1slhDM1YvN7FAIxEin4simGRrp1uXaKetnWQPpK2SNDX/J@fnFefnpOrl5KdrpGlYAEUA "JavaScript (Node.js) – Try It Online"

 Outputs an array of arrays.

# [JavaScript (Node.js)], 87 bytes

<!-- language-all: lang-javascript -->

    n=>[...(m=Array(n)).keys()].map(a=>[...m.keys()].map(b=>-~a>++b?-~a:b).join` `).join`
    `


[Try it online!][TIO-kpr8pt7s]

[JavaScript (Node.js)]: https://nodejs.org
[TIO-kpr8pt7s]: https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/P1i5aT09PI9fWsagosVIjT1NTLzu1slhDM1YvN7FAIxEin4simGRrp1uXaKetnWQPpK2SNPWy8jPzEhQSoAyuhP/J@XnF@Tmpejn56RppGhaamv8B "JavaScript (Node.js) – Try It Online"

Output as a string