I\'m attempting to set up a script to concatenate some variables inside a string if they exist, in order to place the appropriate metadata tags into a rendered HTML
I'd use a ternary operator:
data = "\n"
+ "\n"
+ ( typeof metadata_title !== "undefined" ? "" + metadata_title + " \n" : "" )
+ ( typeof metadata_author !== "undefined" ? "\n" : "" )
+ ( typeof metadata_date !== "undefined" ? "\n" : "" )
+ "\n"
+ "\n"
+ "\n"
+ paras.join("\n\n")
+ "\n"
+ "\n"
+ "\n"
+ ""
;