Let's build a replaceWith
function:
const replaceWith =
(...str) =>
(fallback) =>
str.length === 0
? fallback
: str.shift();
It's a curried function: it takes a list of replacement strings and returns another function which will return the replacements one by one:
const replacements = replaceWith('