The multiplication by 180/PI is not needed. Some programming languages calculate trig functions in radians, which this formula assumes as multiplying by 180/PI is a conversion from radians to degrees. There are 2PI radians in 360 degrees, which simplifies to PI radians in 180 degrees.
The other issue is that formula only works for angles between -90 and +90 deg. Otherwise you have to subtract 180 deg from the result to get the right answer. Angles between -90 and +90 deg are when object 2 is to the right (greater x position) of object 1, so the subtraction of 180 deg can be done when necessary with a If then else block. You mentioned the function atan2. That logic and subtraction is what atan2 does.
This project shows you the code in Hopscotch. It's not too complicated