← Back to challenges

Buggy Code (Part 5)

JavaScriptMediumloopsbugsnumbersdata_structures

Instructions

Mubashir created an infinite loop! Help him by fixing the code in the code tab to pass this challenge. Look at the examples below to get an idea of what the function should do.

Examples

printArray(1) ➞ [1]

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

printArray(6) ➞ [1, 2, 3, 4, 5, 6]

Notes

  • READ EVERY WORD CAREFULLY, CHARACTER BY CHARACTER!
  • Don't overthink this challenge; it's not supposed to be hard.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Buggy Code (Part 7)