This isn't actually for a site, it's NodeJS, but
Code:
How can I improve this function? I was thinking of maybe running a reduce on `find`, but it's all too confusing for me.
Code:
_replace (content, find, replace, delimiter = '', findDelimiter = '') {
if (!Array.isArray(find)) find = [find]
let result = content
find.forEach(ref => {
result = result.split(findDelimiter).reduce((a, e) => a + delimiter + (this._reference[replace][this._reference[ref].indexOf(e)] || e), '')
})
return result
}
How can I improve this function? I was thinking of maybe running a reduce on `find`, but it's all too confusing for me.