Need a function which return next N elements from given array, with given offset, but when offset larger then array length, it must return elements at the beginning of array.
Interface:
slice2(array, chunk, offset);
Examples:
var array = [1,2,3,4,5];
slice2(array,2,2) Output: [3,4]
slice2(array,2,4) Output: [5,1]
slice2(array,3,4) Output: [5,1,2]
1 Answer