from a node js tutorial, instructor declares output but then keeps on redclaring it and then returns output. I would of thought that because output keeps getting re declared when the function returns output it will only return the result of the last line with replace. This doesnt seem to be the case, how does the code work. if the code is too out of context let me know and i will provide more code
let replacer = (temp, replacedwith) =>{
let output = temp.replace(/{placeholder}/g,replacedwith.id)
output = temp.replace(/{other}/g,replacedwith.id)
output = temp.replace(/{something else}/g,replacedwith.id)
return output
}```