There is a NPM package that will do the work for you. You can install it with the following command.
npm install just-modulo --save
Usage copied from the README
import modulo from 'just-modulo';modulo(7, 5); // 2modulo(17, 23); // 17modulo(16.2, 3.8); // 17modulo(5.8, 3.4); //2.4modulo(4, 0); // 4modulo(-7, 5); // 3modulo(-2, 15); // 13modulo(-5.8, 3.4); // 1modulo(12, -1); // NaNmodulo(-3, -8); // NaNmodulo(12, 'apple'); // NaNmodulo('bee', 9); // NaNmodulo(null, undefined); // NaN
GitHub repository can be found via the following link:
https://github.com/angus-c/just/tree/master/packages/number-modulo