공부/프로그래머스

프로그래머스 - 코딩테스트 연습>코딩테스트 입문>숫자 찾기

da_won_2023 2023. 8. 17. 23:42
SMALL
function solution(num, k) {
    const result = num.toString().split("").map((str, idx) => str == k ? idx + 1 : 0).filter(n => n !== 0);
    return result.length ? result[0] : -1;
}
LIST