Skip to content

Commit e3c4c2d

Browse files
committed
배열 회전시키기 / 기초
1 parent 9b5b444 commit e3c4c2d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

imchanyo/array/array_ rotation.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function solution(numbers, direction) {
2+
var answer = [...numbers];
3+
4+
if (direction === "right") {
5+
const rightNumbers = answer.pop();
6+
answer.unshift(rightNumbers);
7+
} else if (direction === "left") {
8+
const leftNumbers = answer.shift();
9+
answer.push(leftNumbers);
10+
}
11+
12+
return answer;
13+
}

0 commit comments

Comments
 (0)