It looks like you're building DOM elements from strings. You just need to add some quotes around result.name:
let inputString = '<input type="button" onClick="gotoNode(\'' + result.name + '\')" />';
Unfortunately, this won't work if result.name contains special characters, and this may be a security vulnerability if result.name is untrusted input. You need to escape it for the JavaScript string literal context, and for the HTML attribute context, like this:
let escapedName = JSON.stringify(result.name)
.replace(/&/g, '&')
.replace(/'/g, ''')
.replace(/"/g, '"')
.replace(/</g, '<')
.replace(/>/g, '>');
let inputString = '<input type="button" onClick="gotoNode(' + escapedName + ')" />';
You should really be doing this with proper DOM methods though. There's no need for escaping when you use proper DOM methods:
var inputElement = document.createElement('input');
inputElement.type = "button"
inputElement.addEventListener('click', function(){
gotoNode(result.name);
});
document.body.appendChild(inputElement);
Just be aware that if this is a loop or something, result will change before the event fires and you'd need to create an additional scope bubble to shadow the changing variable.