Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJulieta Dalla Pozza
4,337 PointsVISUAL STUDIO CODE
My question is about to understand why we work on the console. I am working separately in VS and when i run var message = "hello"; but when i run an alert it does appear in the browser. I dont get what i am doing wrong.
2 Answers
Julieta Dalla Pozza
4,337 PointsHello, i am running from VS
Jason Larson
8,361 Pointsif all you have is
var message = "hello";
there is nothing to display, whether you're talking about the console or in a webpage. If you add a console.log(message);
statement after that, then you could get output in the console.
Having said that, usually you are going to have to attach your js to an HTML file (or have it inside an HTML file in <script> tags). If you are doing it that way, then you would need to open the html file in your browser, then you would inspect the page to view the developer tools, and then look in the console.
The other way to do it would be to install an extension in VS Code. One that I'm aware of is "Code Runner". Just go to Extensions and search for it and install it. Then, in your code, you would save the file and then right-click and choose "Run Code" (or press CTRL+ALT+N) and it will display in an output console.
Jason Larson
8,361 PointsJason Larson
8,361 PointsI'm sorry, but I'm not sure what you are asking. Where are you running var message = "hello"; from, the console, or VS Code? And where are you running the alert from?