function continueSequence(arr){ return function(){ var arrLength = arr.length; var gen = arr[arrLength - 1] - arr[arrLength - 2] + arr[arrLength - 1]; arr.push(gen); return gen; } }