0

I have a problem

I don't know but somehow js is not working on my vscode or maybe I am doing something wrong because it shows me a mistak when I code var= 10; document.write(x); it says that document is not defined

10th Sep 2022, 1:19 PM
MrX
MrX - avatar
3 Answers
+ 2
Are you using vscode to execute js code? document object is not available in runtime environments, that's why it says 'document' is not defined "When an HTML document is loaded into a web browser, it becomes a document object" - W3Schools Link your script with HTML and then load it in browser! See this for more info: https://dev.to/artemismars/nodejs-and-dom-api-2iim
10th Sep 2022, 5:50 PM
Sandeep
Sandeep - avatar
+ 1
var x = 10 // var = 10
10th Sep 2022, 1:30 PM
Jayakrishna 🇼🇳
0
If there is no document (html), just output to console instead: console.log()
10th Sep 2022, 3:43 PM
Lisa
Lisa - avatar