It is brittle to base this code on the position of a string in an arry of strings that is 35 lines above.  Any changes to that array will break this code.

This isn't C. The JS switch statement works for any value, not just integers. So just use switch(fileNameExtension) and use case 'webm': case 'mp4': etc.