function wrapAround(number, start, end) { // Calculate the total range const range = end - start + 1; // Ensure the number is within the range let wrappedNumber = (((number - start) % range) + range) % range; // Adjust the number to the correct // value in the desired range wrappedNumber += start; return wrappedNumber; }