'Cubic bezier function for finding progress given time and two control points

I am trying to find a JS algorithm to find the ypos of a cubic bezier given the xpos. the first and last control points will be (0,0) and (1,1) and it should throw an error if any of the inputted control points' xpos is less than 0 or greater than 1, just like in CSS. the function will be called like

cubicBezier(p1x, p1y, p2x, p2y, time)

I spent like half an hjour searching it on google but nothing seemed to work.. I only fornd a buch of mathematical formulas when I was looking for an algorithm. Even when I turned my eyes to stackoverflow I couldn't find anything other than complex mathematical formulas and stuff in c++
the top left point is going to be p1 and the other point is p2.

bezier



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source