I have a template string:
const template = "Answer to {question} must be {YES} and answer to {question} must be {4}";
and an array of values:
const array = ["Is it late?", "What time is it?"];
What I'm trying to achieve is to replace each occurrence of {question} by an element of my array, respecting the index, and preserving the braces. Result string should look like that:
"Answer to {Is it late?} must be {YES} and answer to {What time is it} must be {4}"
I have the notion that it is achievable with replace, or with split and join, but I don't manage to make it work. Any idea?