Need help coding enemies to new web game in HTML/JavaScript

I think you should be reading a lot of articles on game creation and looking at using a library.
There are a bunch of ways of doing collision detection…AABB (non rotating rectangles), SAT (convex polygons), circle, pixel perfect (pixel to pixel or bit masks), etc. For this youd prolly want SAT and I aint writing that :stuck_out_tongue_winking_eye: , so Id use a library. And your going to keep on having questions as theres still a lot more to all this.
If I was you Id start looking for a library. As I havent looked at this sorta stuff for years the only thing that comes to mind is Phaser. Its not as active as it once was but is still being updated and all that. I like that one because there are LOTS of tutorials and their forums still have some activity. It has everything and the kitchen sink. I havent written a game in literal decades but I want to sooner or later and Id prolly just use Phaser because I like a lot of the ways it does things. Failing that itd prolly be PixiJS with a SAT library, no idea for audio.
I could add collision detection to your example but prolly not till the weekend as Im going through a no energy phase…again…sorry.