Last active
February 18, 2020 17:11
-
-
Save Heavyblade/9a3e135df75fbb89e6d3866864241485 to your computer and use it in GitHub Desktop.
cicle.js
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
var array = [1,2,3,4,5,6]; | |
function cicle(arr) { | |
return function() { | |
arr.push(arr.shift()); | |
return arr[arr.length -1]; | |
} | |
} | |
var getNext = cicle(array); | |
console.log(getNext()); | |
console.log(getNext()); | |
console.log(getNext()); | |
console.log(getNext()); | |
console.log(array); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment