A face-to-face question that does not use a for loop and returns an array based on the passed parameters

topic description

instead of using for loops, an array is returned based on the passed parameters

sources of topics and their own ideas

when I saw the face-to-face test questions on the Internet, when I typed, I found that some of the code using comments was incorrect, and I don"t know why

related codes

var num = 5;
function show(n) {
    var arr = [];
    return (function fn() {
        arr.unshift(n);
        n --;
        if(n != 0) {
            fn() 
        }
        // else {
        //     return arr;
        // }
        return arr;
    })()
}
Feb.18,2022

you mean to use else {reture} instead of using direct return? Like down there? It's no problem to add your comments directly

var num = 5;
function show(n) {
    var arr = [];
    return (function fn() {
        arr.unshift(n);
        n --;console.log(n)
        if(n != 0) {
            fn() 
        }else {
             return arr;
        }
        
    })()
}
undefined
show(num)
VM3626:6 4
VM3626:6 3
VM3626:6 2
VM3626:6 1
VM3626:6 0
undefined

as far as I understand it, it is OK to comment on that piece of code. I don't know what you mean by incorrect.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35b7a-2bfaa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35b7a-2bfaa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?