AniUI Academy
easy+150 XPPractice

Generate a range of numbers

Rendering ten skeleton rows or a row of page numbers means having an array to map over. JavaScript has no built-in range, so every codebase grows one.

Implement range(start, end, step). Return an array of numbers beginning at start, increasing by step each time, and stopping before endend itself is never included. step defaults to 1 when it is not supplied. If step is zero or negative, return an empty array. If start is greater than or equal to end, return an empty array. Negative values of start and end are ordinary numbers and work the same way.

What it has to do

  • end is exclusive: range(0, 5) stops at 4.
  • step defaults to 1 when omitted.
  • Return [] when step is zero or negative.
  • Return [] when start >= end.
  • Handle negative start values.

Your workspace

Try it yourself
Loading playground...

Ready to check it?

5 tests run against your code, right here in your browser. Sign in to claim the XP when you pass.

AI Crack & Solution Assist

Stuck? Get instant AI hints or break down the optimal solution.

Stuck? The javascript course covers everything this challenge needs.