Here's a little demo project to show how you can solve a two bone chain inverse kinematics using the law of cosines.
Here's the p5Js sketch: https://editor.p5js.org/admiralra/sketches/0GGfkLXMh