My formula can be simplified to https://www.desmos.com/calculator/pf9y0vjoep
Including your parameters, default scale and offset, we end up with:
```
triangleWave2 = (period = 1, amplitude = 2) => (
x => Math.abs(x / period + .25 - Math.floor(x / period + .75)) * 4 * amplitude - amplitude
)
```