- 3
Why I m not getting any output
var dog = 20; var cat = 5050; document.write(dog + cat); //not getting output
12 Respuestas
+ 6
document.write is not in node.js, it's in standard Javascript, so you're mixing incompatible code.
For that, you need to change document.write to console.log instead
+ 1
It seems to work fine for me. Perhaps there is something wrong with the environment you are running it in. Is it possible I could know where in order to help?
0
I have runned in solo learn node.js
0
The problem is due to saying document.weite, because in node.js (in SoloLearn at least) it cannot run that. Try running it in web in SoloLearn (in the tab Javascript)
0
Thank you for your help. But I also checked in spck pro app in my mobile in that also getting error
0
Have you executed that in a node.js environment as well?
0
Yes
0
So that must be the problem. Node.js environments cannot be used to run this code as it uses document.write, which is used for web pages. So therefore it can only be executed in web documents (or in the script tag of a html document)
0
It's bizarre that we can't use '//' but '/**/' as the comment.
0
That means thare is lots of difference between javascript and node.js
0
Yes, as one is more file based while the other (node.js) is more console based
0
Thanks for ur help