[JS] 프로그래머스 0단계: 정답률 85%

ahyes·2022년 12월 11일
0
post-thumbnail

안녕하세요
오늘은 정답률 85% 문제를 풀어보도록 하겠습니다.

  1. 인덱스 바꾸기
function solution(my_string, num1, num2) {
    var answer = [...my_string];
    answer[num1] = my_string[num2];
    answer[num2] = my_string[num1];
    return answer.join('');
}
  1. 암호 해독
function solution(cipher, code) {
    return [...cipher].filter( (x,index) => index%code === code-1 ).join('')
}
profile
티스토리로 이사갑니다. https://useyhnha.tistory.com/

0개의 댓글