if you hate JS and think it's dumb, but still have to use it, look into Eloquent Javascript (free) https://eloquentjavascript.net/ and the mozilla docs https://developer.mozilla.org/en-US/docs/Web/JavaScript.Eloquent JS is written by someone who also hates JS, but understands it very well. I used them while I worked on the Microtonal Music Grid (still in progress)
there's already a stack overflow thread https://math.stackexchange.com/questions/312640/how-to-solve-for-the-fouriest-number
if you hate JS and think it's dumb, but still have to use it, look into Eloquent Javascript (free) https://eloquentjavascript.net/ and the mozilla docs https://developer.mozilla.org/en-US/docs/Web/JavaScript.
Eloquent JS is written by someone who also hates JS, but understands it very well.
I used them while I worked on the Microtonal Music Grid (still in progress)