I'm detecting extensions then taking actions based on the extension. So my question is why doesn't this work, seems logical enough eh?
var ext = url.split('.').pop().toLowerCase();
if (ext == 'avi' || 'mpg' || 'mpeg' || 'mp4' || '3gp') {
This is a video (this always returns true...?)
} else if (ext == 'jpg' || 'jpeg' || 'gif' || 'png' || 'bmp') {
This is a picture
} else {
This extension isn't supported here
}
But this does? Unnecessary overhead?
var ext = url.split('.').pop().toLowerCase();
if (ext == 'avi' || ext == 'mpg' || ext == 'mpeg' || ext == 'mp4') {
This is a video
} else if (ext == 'jpg' || ext == 'jpeg' || ext == 'gif' || ext == 'png') {
This is a picture
} else {
This extension isn't supported here
}
Is there a syntax issue I'm missing to make this work like example 1 without hitting the variable over and over? Concerned because this list is a lot larger than what is pictured in regards to the amount of extensions and seems like a lot of unnecessary code when it's all said and done.