Need a function to loop through an array to check tags

Hello,

I’m new to scripting so any help and explanations you can give me will be a massive help.

For a project I’ve been asked to create a function in javascript that loops through an array that makes blocks. In the game, you shoot the block and the block changes colour to red, then yellow, then green then if you shoot a green one the block is destroyed and you lose your points. I need a way to check all the blocks have turned green (or been destroyed) so that the “win” screen can load up.

Sorry if I’ve done anything, again completely new to all this and this is the first time I’ve posted on here.

Cheers.

(Here’s the code for spawning the blocks I mentioned)

for (var row = 0; row < 5; row++)
{
    for (var col = 0; col < 5; col++)
    {
        var latestBlock = Instantiate (block, Vector3(this.transform.position.x + blockWidth*row, this.transform.position.y + blockHeight*col, this.transform.position.z), Quaternion.identity);
          
        blockArray.Add(latestBlock);

        yield WaitForSeconds (0.1);

You can create script that holds blocks HP and attach it to block.
Then every time you shoot block you lower the HP of block. You check if all blocks in array have 0 hp and if so you load the win screen.
Hope this helps.