알고리즘/프로그래머스
Lv.0 - 순서 바꾸기
hoj0806
2024. 5. 3. 18:10
문제
풀이코드
const solution = (arr , n) =>
[...arr.filter((item, index) => index >= n), ...arr.filter((item, index) => index < n)]
코드 설명
filter 메소드를 통해 배열을 나누고 스프레드 연산자로 배열을 합쳐 리턴