hey all.. i need a function that would return a previous and next numbers, but only within my numbers range. so, for example, if my range is from 0 to 7, and im on 6 - next should return 7. if im on 7 - next should return 0 (it circled back to it).
same for previous, if im on 0, previous should be 7. I think modulo can be used to figure this out, but cant figure out how. the function should take 3 arguments- current number we are on, maximum number and if we are going back or forward. something like
getPreviousOrNext(0, 7, "next" or "prev" )
thanks!!!