Please tell me how to write a function.

generate the corresponding loop based on the given number. If 2 is given, a double cycle is generated, and 3 is a triple cycle
if 3 is given, then

for (let i = 0; i < arr.length; iPP) {
        for (let j = 0; j < arr.length; jPP) {
            for (let k = 0; k < arr.length; kPP) {
                
                }
            }
        }
 }
Mar.09,2021

Recursive


f(arr, 3, [])

function f(arr,k,temp){
    if(k<=0){
        let sum = 0
        let r =[]
        for(let i = 0; i < temp.length; iPP){
            sum += temp[i]
            r.push(temp[i])
        }
        if (sum  === hz) {
            result.push(r)
        }
        return
    }
    for (let i = 0; i < arr.length; iPP) {
        temp.push(arr[i])
        f(arr, k-1, temp)
        temp.splice(temp.length-1, 1)
    }
}


this kind of demand can usually be solved through negotiations, so let n count and then n = 0 jump out of the box. It is estimated that it will take some tricks and tricks to force loop to solve the problem.

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-1b387a7-2b96c.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-1b387a7-2b96c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?