I would like to format a string using positional placeholders in Javascript. For example, in Python I could do:
st1 = 'name'
st2 = 'javascript'
sentence = "My %s is %s." %(st1, st2)
print(sentence)
And I would get
My name is javascript.
as the output. Clearly it wouldn't work out in javascript (at least not exactly the same way), I know of using replace
var st1 = 'name';
var st2 = 'javascript';
var sentence = "My %s is %s".replace('%s', st1);
console.log(sentence);
But that would only replace the first occurrence of '%s'.