Created
August 5, 2019 22:59
-
-
Save isdampe/2c0dd564a398df60cee5beb986c73efd to your computer and use it in GitHub Desktop.
This file contains 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
let theArray = [5, 9, 3, 15, 41, 2, 19]; | |
function arrayShift(arr, idx) { | |
console.log("Starting array is"); | |
console.log(theArray); | |
for (let i=idx; i<arr.length - 1; ++i) { | |
console.log("Step"); | |
theArray[i] = theArray[i + 1]; | |
console.log(theArray); | |
} | |
theArray.pop(); | |
console.log("Done, result was") | |
console.log(theArray); | |
} | |
// int main(void) { ... | |
console.log("Will remove 15"); | |
arrayShift(theArray, theArray.indexOf(15)); | |
console.log("Will remove 9"); | |
arrayShift(theArray, theArray.indexOf(9)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment