js modulo not working

JavaScript
// The JS % operater is REMAINDER not MODULO
// For modulo behaviour use
function mod(n, m) {
  return ((n % m) + m) % m;
}
Source

Also in JavaScript: