Calculate the mod of collection index
JavaScript
const mod = (a, b) => ((a % b) + b) % bTypeScript
const mod = (a: number, b: number): number => ((a % b) + b) % bExamples
mod(-1, 5) // 4
mod(3, 5) // 3
mod(6, 5) // 1const mod = (a, b) => ((a % b) + b) % bconst mod = (a: number, b: number): number => ((a % b) + b) % bmod(-1, 5) // 4
mod(3, 5) // 3
mod(6, 5) // 1