• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    미해결

for 반복문 관련 문의

21.02.24 10:27 작성 조회수 78

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한 것으로 교체시 결과가 다른 이유를 모르겠습니다.

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!