← Back to challenges

Pyramid Arrays

JavaScriptHardarrayslanguage_fundamentalsloops

Instructions

Given a number n, return an array containing several arrays. Each array increments in size, from range 1 to n inclusive, contaning its length as the elements.

Examples

pyramidArrays(1) ➞ [[1]]

pyramidArrays(3) ➞ [[1], [2, 2], [3, 3, 3]]

pyramidArrays(5) ➞ [[1], [2, 2], [3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5, 5]]

Notes

n will be a positive integer.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Total Count of Numbers in a MultiDimensional Array