강의

멘토링

커뮤니티

Inflearn Community Q&A

icandoa1346's profile image
icandoa1346

asked

Jeju Coding Base Camp Code Festival: JavaScript 100 Questions

Problem 84: Number Picking

for 반복문 관련 문의

Written on

·

184

0

function solution(argStrNum, argLen) {
    let arrRet = [];
    const combiAll = (strPre, strNum) => {
        for (let idx = 0; idx < strNum.length; idx++)
        // for (let idx in strNum)
        {
            arrRet.push(strPre + strNum[idx]);
            combiAll(strPre + strNum[idx], strNum.slice(idx + 1));
        }
    };
    combiAll("", argStrNum);
    console.log(arrRet);
    arrRet = arrRet.filter((x) => x.length === argLen);
    console.log(arrRet);
}

const strNum = "1723";
const intLen = 2;
console.log(solution(strNum, intLen));

위 코드에서 for 반복문을 comment한 것으로 교체시 결과가 다른 이유를 모르겠습니다.

javascript코테 준비 같이 해요!

Answer

This question is waiting for answers
Be the first to answer!
icandoa1346's profile image
icandoa1346

asked

Ask a question