I have a file that has an extention either:
.doc or .docx
I wanted to link it this way:
document.getElementById("file").innerHTML = "View file sent <a href='../folder/filename" +
(what syntax do I need to add here if I wanted to print which extention file is exist on that folder)
In PHP we can do this
var1 = ".doc";
var2 = ".docx";
var1 ? var1 : var2;
What is the equivalent of this in JavaScript?
I’m not sure what you’re doing here:
This will always return “.doc” because var1 will always evaluate to true, regardless of whether you’re using PHP or Javascript.
It sounds like you might be after something like this instead: