Write countDown(n) that returns the array [n, n - 1, …, 2, 1].
nis a whole number from0to1000.countDown(0)returns an empty array[].- Solve it without loops: no
for,while,.map,Array.fromand so on. Instead,countDownshould build its answer fromcountDownof a smaller number.
Input: n = 3
Output: [3, 2, 1]
Input: n = 1
Output: [1]
Input: n = 0
Output: []