Solving a system of linear equations using javascript

I need to write a code to do a polynomial interpolation for any number of user determined points to create a curve that goes through all points on p5js. I think I’ve figured out how to go about creating the matrices using a for loop with 2D arrays to fill with data points with respect to a parameter, t. However, to easily solve the arrays to get the polynomial coefficients, I’m not sure how to go about trying to solving for it, as I’m not sure how to put math.js into the p5js editor on browser. I’m not even sure that would be helpful since as far as I’m aware, math.js’ matrix functions only work for n x n, whereas the ones I’m trying to solve would be A = n x 4 matrix. If there’s any code that could be used to solve this problem, I would love to see it, because at this point, I am very lost.