math - Javascript modulo not behaving - Stack Overflow
This is not a bug, there's 3 fonctions to calculate modulo, you can use the one which fit your needs (I would recommand to use Euclidean function) Truncating the decimal part function console.log( 41 % 7 ); // 6 console.log( -41 % 7 ); // -6 console.log( ...