← Back to challenges

Array of Consecutive Numbers

JavaScriptHardarraysloopslanguage_fundamentals

Instructions

Implement a function that returns an array containing all the consecutive numbers in ascendant order from the given value low up to the given value high (bounds included).

Examples

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

getSequence(98, 100) ➞ [98, 99, 100]

getSequence(1000, 1000) ➞ [1000]

Notes

  • ES6 deepening (for medium or higher level users): try to implement a one-liner function that calls a single method.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Negate the Array of Numbers