As you said @ azeós in your comment, the error that can be seen in the small piece of code you have shared is that you associate custom a result. At the moment we do not know what the custom variable is, but what if I can tell you that the instructions that are executed are:
document.getElementById ("result"). innerHTML = custom
result = document.getElementById ("result"). innerHTML;
Therefore, you are storing in "result" the content of "custom", which has nothing to do with the HTML content that has the element with id "result" of the page. Surely this will be the main problem, and usually happens by copying and pasting without being very careful, it has all happened to us. It is a matter of time before you have the ability to see it quickly, and that these problems do not affect you at all.
In short, you would have to modify the line ...
var result = document.getElementById("resultado").innerHTML = custom;
To leave it like this ...
var result = document.getElementById("resultado").innerHTML;
So that you can see a clearer example of what I am saying, here is an example where a multiple value assignment is made.
var objetoCustom = "PrimerMensaje"; // Este objeto no se sabe si está inicializado siquiera
var objetoHtml = "htmlInterno"; // Esto reemplazaría el código de document.getElementById("resultado").innerHTML
var result = objetoHtml = objetoCustom;
alert(result);