Fix negative modulo (reminder operator %
)
Simplified using ES6 Arrow function, and without dangerously extending the Number prototype
const mod = (n, m) => (n % m + m) % m;console.log(mod(-90, 360)); // 270 (Instead of -90)
%
)Simplified using ES6 Arrow function, and without dangerously extending the Number prototype
const mod = (n, m) => (n % m + m) % m;console.log(mod(-90, 360)); // 270 (Instead of -90)