JavaScript buttons now require a button click before they execute at all. Some basic logic has changed as a result of this. If you want to change the button, you can do so, but only after the user clicks the button. The basic script for this looks like:
document.querySelectorAll("[name="+element.name+"]").forEach(
input => input.title = input.value = "Hello World"
);
If you want to change the label when the page loads, you can do so with record types and page layouts, but the values will still be hard-coded to whatever specific values you configure.
There may be another way to do whatever it is you're trying to do, but the technique outlined in the previous question/answer will not work.