I define in Node.js a global variable and give it a value. A variable with the same name (from my point of view the global variable) is changed in a sub function. However, the value of the global variable remains the same.
Re-named the variable
global.reo = "HTMLcode{${table}}HTMLcode"; //global variable "reo" defined, as html code is translated in this page I just put "HTMLcode" instead or real HTML code
...
function setResHtml(sql, cb){
...
return cb(table);
});
let sql ='SELECT * FROM table';
setResHtml(sql, resql => {
reo = reo.replace('{${table}}', resql); // changed global value "reo"
console.log(reo); // shows the change
});
console.log(reo); //doesn't show the change