How do I output a variable from JS to html?

There is a code of JS:
var text = 'test';
var word = reduplicate(text);


So the contents of the variable word in the browser is displayed, but how to make it visible in the html source code? (without a redirect to get ?word=)
July 12th 19 at 17:08
5 answers
July 12th 19 at 17:10
how to make so that it is visible in the html source code?
Not to do so. Source code is what pays the server. In your case the server does not give anything directly, and the string is generated on the client.
July 12th 19 at 17:12
It seems no - source code is that was received by the client from the server. And js it is already transforming the basis of the inherent logic programmer. Don't know how things in nodejs, but it's usually true.
July 12th 19 at 17:14
on the client :D

// JS
document.querySelector('body').innerHTML = word;

July 12th 19 at 17:16
No way.
July 12th 19 at 17:18
a little bit of php, htaccess a little bit, a little ajax
but what bike? maybe the more simple the solution is?

Find more questions by tags JavaScriptHTML