# javascript find smallest difference between angles

var x = Math.PI * 1.9; var y = Math.PI * 0.1; Math.atan2(Math.sin(x-y), Math.cos(x-y)); // -Math.PI * 0.2

**Here is what the above code is Doing:**

1. We’re using the atan2 function to calculate the angle between two points.

2. We’re using the sin and cos functions to calculate the x and y components of the angle.

3. We’re using the Math.PI constant to convert from radians to degrees.