JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id="output" style="width: 99%; height: 20em; background-color: #ffc"></textarea>
JavaScript
// log() just writes a message to the text area
function log(message) {
$('#output').val($('#output').val() + message + "\n");
}
// redefineFunction() will take a function reference and
// reassign it to a new function
function redefineFunction(f) {
f = function(x) { return x * 3; };
}
// initial version of go()
function go(x) {
return x;
}
log(go(5)); // returns 5
// redefine go()
go = function(x) {
return x * 2;
}
log(go(5)); // returns 10
// redefine go() using redefineFunction()
redefineFunction(go);
log(go(5)); // returns 10, I want it to return 15