How to Repeating command in js

I am trying to instantiate a zombie object every 1 seconds. but it only does it once how can I make it repeat continuously?

CODE:
#pragma strict

var z : GameObject;

yield WaitForSeconds (1);
Instantiate (z);

function Start () {

}

function Update () {
}

This will spawn 10 zombies, each after 1 second

function Start(){
    SpawnZombies();
}
     
function SpawnZombies(){
     for(var i : int = 0; i < 10; i++){
        //instantiate here
        yield WaitForSeconds(1);
    }
}

function SpawnZombies()
{
while(true)
{
yield WaitForSeconds(1);
Instantiate(z);
}
}

function Start()
{
  StartCoroutine(SpawnZombies()); 
}

It seems like you’re performing the Instantiate function completely outside the Update method. Therefore it only runs it once upon class initialization.

Here’s something that should work with the Update method:

var z : GameObject;
var spawnTime: float = 1;

private var lastSpawn : float = 0;

function Update () { 

    lastSpawn += Time.deltaTime;

    if (lastSpawn > spawnTime) {
        lastSpawn = 0;
        Instantiate (z);
    }

}

Or (as YoungDeveloper beat me to it) with yield in a coroutine:

var z : GameObject;
var spawnTime: float = 1;

function Start(){
   SpawnZombies();
}
 
function SpawnZombies(){
   while (true) {
      Instantiate (z);
      yield WaitForSeconds(1);
   }
}