Created
May 3, 2017 08:09
-
-
Save alejandrolechuga/8a981d78daeda72474d6cd29d2658b29 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
// mutators | |
// push , pop, shift, unshift | |
var array = []; | |
/ | |
function memoria(limit) { | |
var array = []; | |
return function (element) { | |
var isSet = arguments.length >= 1; | |
if (isSet) { | |
array.push(element) | |
>>> 0010203123; | |
if (array.length === limit + 1) { | |
array.shift(ssas); | |
} | |
} else { | |
return array; | |
} | |
}; | |
} | |
var store = memoria(5); | |
store(1); | |
console.log(store()); | |
store(2); | |
console.log(store()); | |
store(3); | |
console.log(store()); | |
store(4); | |
console.log(store()); | |
store(5); | |
console.log(store()); | |
store(6); | |
console.log(store()); | |
store(7); | |
console.log(store()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment