Menu

is there a good way to check the contents of a folder?

Reddit r/learnjavascript·u/Comfortable_Tea_2825·6 days ago
#tKCMx00F
#word#want#create#function#article
Reading 0:00
15s threshold

I'm trying to make a semi-scalable talking robot program. In my mind I am imagining I will have to make an array. I have a bunch of word mp3 files, and I want users to be able to add more word recordings to the robot by just copy/pasting into the word folder.

when the page loads I want to create a button for every word in the words file.

I don't want a perfect answer because I want to have to work my way around this in my own way, but is there a way, without using PHP, that I can see the mp3 files? from there I just have to create a foreach function to create a button in the html that plays the clip onclick.

This is my separate function that the buttons play the clip with:

function playClip(characterName, clipName) { const audioDest = 'VoiceLines/' + characterName + '/' + clipName + '.mp3'; const audio = new Audio(audioDest); console.log(audioDest); audio.play().catch(error => { console.error("Audio playback failed:", error); }); }