can anyone suggest a snippet or a short method to solve this:
array = [a,b,c,d,e,f]
currentIndex = 2;
getOffset(array,currentIndex,2); // 2+2 = 4 -> return 'e'
getOffset(array,currentIndex,-2); // -> return 'a'
getOffset(array,currentIndex,-3); // -> return 'f'
getOffset(array,currentIndex,-4); // -> return 'e'
getOffset(array,currentIndex, 5); // -> return 'b'
So if the the targetted index is bigger than array.length or < 0 -> simulate a circle loop inside the array and continue to step inside the indexes.
Can anyone help me? I tried, but got a buggy script :(
TY!