Created
May 29, 2022 07:09
-
-
Save peterkarn/6326fe0665dc7f031da5a132ff4226d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DoubleDndedArray { | |
constructor(arr) { | |
this.arr = arr; | |
} | |
firstToEnd() { | |
const el = this.arr.shift(); | |
this.arr.push(el); | |
} | |
lastToStart() { | |
const el = this.arr.pop(); | |
return this.arr.unshift(el); | |
} | |
} | |
const testArray = new DoubleDndedArray(['1', '2', '3']); | |
testArray.firstToEnd(); | |
testArray.firstToEnd(); | |
testArray.firstToEnd(); | |
console.log(testArray.arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment