+ 1
Why Is This Code working in sololearn but not in node.js?
2 Answers
+ 2
this will work if you make some tweaks like providing html code
+ 1
"Node.js is an open-source, cross-platform, JavaScript run-time environment that executes JavaScript code outside of a browser." Wikipedia.
Since it's not run in your browser there's no document to write in. Node.js is not the same as JavaScript in your browser! (or to be exact the syntax is the same but not the APIs).