KaboomJS mobs not spawning

Question:
I have a function that is supposed to spawn mobs, but it’s not working.

Repl link:
replit.com/@element1010/Bean-Defense#code/main.ts

loop(1, () => {
    let comps = [];
    let choice = randi(4);

    switch(choice) {
      case 0:
        add([
          sprite("apple"),
          pos(width(), rand(height())),
          "apple"
        ]);
        break;
      case 1:
        add([
          sprite("coin"),
          pos(width(), rand(height())),
          "coin"
        ]);
        break;
      case 2:
        let ghostChoice = randi(4);
        //comps.push(sprite("ghosty"), "ghost");
        switch(ghostChoice) {
          case 0:
            add([
              sprite("ghosty"),
              pos(width(), rand(height())),
              "ghost",
              health(10),
              {
                size: "tiny"
              }
            ]);
            break;
          case 1:
            add([
              sprite("ghosty"),
              pos(width(), rand(height())),
              "ghost",
              health(20),
              {
                size: "small"
              }
            ])
            break;
          case 2:
            add([
              sprite("ghosty"),
              pos(width(), rand(height())),
              "ghost",
              health(35),
              {
                size: "medium"
              }
            ])
            break;
          case 3:
            add([
              sprite("ghosty"),
              pos(width(), rand(height())),
              "ghost",
              health(50),
              {
                size: "big"
              }
            ]);
            break;
        }
        break;
      case 3:
        add([
          sprite("bag"),
          pos(width(), rand(height())),
          "bag",
          health(75)
        ]);
        break;
    }
  });

‘Not working’ is very vague. Could you describe what is happening/not happening and have you tried looking at any errors if there are any?