I have a template in a String and I want to replace a few of the placeholders with the values that I have in another string. For every placeholder that I replace, I also wan
You can use ternary operator (empty string evaluates to false)
template_html = template_html.replace(/#ADDRESS2#/g, val.address_2 ? ''+ val.address_2 : '');