We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9b5b444 commit e3c4c2dCopy full SHA for e3c4c2d
imchanyo/array/array_ rotation.js
@@ -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