Reputation: 1846
I have a path which is passed down to me as a javascript variable, which will reference to an image (maybe).
../app/assets/icon.png
. In the case that the path is invalid or doesn't exist, I want to use a different file, located somewhere else. In the end, it should look something like this:
var verifiedPath = existsAndIsValid(path) ? path : '../app/default/icon.png'
Is there a simple one-liner in which I can do this?
Upvotes: 5
Views: 4740