Browser Usage
Add the script
Section titled “Add the script”<script src="/path/to/Maths.js"></script>Use the global Maths object
Section titled “Use the global Maths object”<script> console.log(Maths.avg(12, 18, 24)); // 18 console.log(Maths.clamp(42, 0, 10)); // 10 console.log(Maths.distance(0, 0, 3, 4)); // 5</script>- Load
Maths.jsbefore your app script. - Methods throw errors for invalid input; use
try/catchif inputs are untrusted.