MV How to check if all enemies within a Troop are dead

I was wondering how do I check it all the enemies with a given troop are all dead? I am using Yanfly's Base Troop Plugin to run a specific Troop's events so all the battles will follow the same set of events.

Yanfly's Base Troop: http://www.yanfly.moe/wiki/Base_Troop_Events_(YEP)
Do a conditional branch with

$gameTroop.aliveMembers().length === 0
doesn't matter, because the second the last enemy is dead, the engine ends the battle even before processing any troop event. So your troop event wouldn't run anyway.

Please take two steps back and explain to us what you really want to do. Then we might be able to explain a workaround to you.
there are several different workarounds with different advantages and disadvantages, so we need nmore info to guess which way would be best to use here.
Oh, good point Andar.

Yeah, best to tell us what you're trying to do.
I'm I wasn't clear with my intentions. I have my battle hud made with SRD Hud Maker (http://sumrndm.site/hud-maker/) Whenever battle end the Hud pieces stay on even after the monsters are are dead. What I was trying to do is flip the Hud elements off with a switch.

I tried use javascript that @Trihan suggested but it didn't turn the Hud elements off.
As Andar said, the moment the last enemy dies the battle ends and your troop event won't be running any more, so it'll never hit that code.
instead of trying to force the HUD off, how about you try to bughunt it to find out why it doesn't go off automatically?
Because that seems to be the problem, and you need to solve problems in bughunting, not hide them behind overrides - because the bug might do more than just keep the HUD when it should go off.
After a quick look through the plugin parameter of Hud Maker, I found a way to control when the battle hud is on. I just used the code @Trihan suggested and instead of equal to zero I set the hud to stay on when its greater than zero. This allowed the Hud to turn off once the enemies all died. I can't believe the answer was so simple. XP

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-if-all-enemies-within-a-troop-are-dead.137069/