var srcType = source.slice(source.lastIndexOf('.'));
//srcType = fileExtension
var imageFormats = ['.jpg','.png','.gif'],
videoFormats = ['.ogv','.png','.gif'];
// two lists, acceptable video/image types
var htmlSting = ''; / /initialize the htmlstring
if (srcType in imageFormats) //heres where my question is!!!
htmlString = '<img class="empty" id="it" src="'+source+'"> </img>';
else
htmlString = '<video class="empty" id="it" src="'+source+'" controls> </img>';
// these statements choose the proper media type.
Ok, so heres the deal: I am coding something that needs to choose html based on a filetype. is there a way to achieve the (srcType in imageFormats)? This doesn't work. Do I need a for loop? I could always use or's in the html, but that would be exhaustive as we add formats. Reason I don't like a for loop is that it uses precious time in a time-critical area.