[JavaScript] - How To Create An Array Of Phaser 3 Audio?

Hi,

I am trying to create a JavaScript array of Phaser 3 audio.

I have below but it errors out when viewed in browser:

var MusicTemp;
const Music = [];

this.load.setPath('data/music');
this.load.audio('MusicTemp', [ 'BGM_Title.mp3' ]);
Music = this.sound.add('MusicTemp');

Any help would be appreciated, thanks!

Jesse

Web demo can be played on Itch website below:

Phaser_3_Demo_2023-04-12_1742

Hi, did something different which I am happy with:

var SFX_Player_Jump;
var SFX_Collect_Star;
var SFX_Player_Hit_By_Bomb;
var SFX_New_Bomb;

var BGM_Music;

function LoadAllAudio ()
{
    this.load.setPath('data/sound');
    this.load.audio('SFX_Player_Jump', [ 'SFX_Player_Jump.mp3' ]);
    this.load.audio('SFX_Collect_Star', [ 'SFX_Collect_Star.mp3' ]);
    this.load.audio('SFX_Player_Hit_By_Bomb', [ 'SFX_Player_Hit_By_Bomb.mp3' ]);
    this.load.audio('SFX_New_Bomb', [ 'SFX_New_Bomb.mp3' ]);

    this.load.setPath('data/music');
    this.load.audio('BGM_Music', [ 'BGM_Title.mp3' ]);

}

function PlaySoundEffect (index, volume, loop)
{
    index.setVolume(volume);
    index.setLoop(loop);
    index.play();
}

function PlayMusic (index, volume, loop)
{
    index.setVolume(volume);
    index.setLoop(loop);
    index.play();

}

For one-and-done playback, you can skip sound.add() and do

this.sound.play('SFX_Collect_Star', { loop: false, volume: 1 });

Sorry that crashes when viewed in browser?

Please view my audio JavaScript file below:
https://bitbucket.org/jesseleepalser/phaser-engine/src/e545566dcf8f2be0e0a82b60504ee529f2beee85/coreAudio.js#lines-1