New To JS and Visual Studio

I just started to learn JS and am using Visual Studio Code. I am trying to follow an online tutorial. I think I am copying the tutorial exactly but I guess not. Here is a screen shot of my attempt:

Hopefully you can see it.

I’ve entered a simple JS command VS: console.log(‘hello’);

After saving I expected ‘hello’ to show in the Console on the right. It doesn’t so I must be doing something wrong? Help, please.

Where is the tutorial? I don’t see the HTML so it is better if we can see the entire tutorial.

What does your index.html file contain? That’s where the problem is likely to be when the script isn’t even loading.

JS requires a runtime environment, so you might either embed it in a web page (say index.html) or run it from a shell using node:

node main.js

PS: As for vscode, I find the code runner plugin quite useful.

Well I was going to say things like that but I was waiting for a reply from the person requesting help. Either Engine44 is not serious about getting help or they figured it out by looking at the HTML and is not updating us. Or maybe they are just not getting notification of replies.

Hello,

I’m in Netherlands and just woke up. I’m going to try a few things and I’ll get back to you. Thanks.

1 Like

I went back in the tutorial (https://www.youtube.com/watch?v=hdI2bqOjy3c&list=PL87rE2-Z2zrO_KqzF7MSUK7DL312eas8P, 7:40) to try to track down the issue. When he enters his first script in the html file, he saves it and a popup appears. When I do the same, there is no popup. Chrome is set to allow popups. This appears to be a functional/usage issue involving Visual Studio. I can change the ‘JS Crash Course’ string in the header and the change appears. So VS is working at least partially. Thanks.

I just reloaded and the popup worked. Now to the next step.

Things seem to be working now. I didn’t properly load the src file. Thanks for responding.

I think that tutorial is not good. First, I do not like videos for learning technical things like that so my opinion is biased. I prefer written text that I can conveniently move around in and that I can copy the code from. For those of us that want to help a video makes things a bit difficult, especially that video, since we must watch the introduction or at least we are not sure where to skip to. Next, I hear many errors. He seems to imply that other versions of JavaScript are variations of ECMAScript and that is not correct.

In that video when he introduces the console class he shows saving the JavaScript and magically the code is executed. He does not explain how that happens. I think that is what confused you. He explains many relatively unimportant things; things that could be explained later, but does not explain some critical fundamental things.

JavaScript can be executed as embedded in HTML; all one file. For large JavaScript code it is better to make the code a separate file or files. I think he should start out by showing how to execute the beginner/sample code as embedded in (part of) the HTML file. There is nothing wrong with doing that for simple programs and it would make it easier for the student. He does say something about script tags, as if you should already understand that, but if you are not familiar with script tags then things are likely to be confusing.

He says we can use the developer tools and explains how to do that. He says that for Windows we can use F12. Well Windows is not a browser and F12 works (to get the developer tools) in all the major browsers.

That is from the first ten minutes. You have just awoken in the Netherlands and I am ready for sleep in California. I am sure that others will help as needed.

1 Like

Thanks. I’m ok at the moment. Also, I’m in no rush, lol.

I fully concur with @SamuelCalifornia about video tutorials… whatever works for you of course, but here’s a tutorial I would recommend:

Thanks

Most forums ask that we create a new thread for new questions. Using one thread for multiple questions can become difficult to follow, difficult to provide help and difficult for others to benefit from the help that is provided.

2 Likes

Yes, sorry.

Your main.js file location is most likely not referenced in the index.html file.
Also make sure both the files are placed in the same project directory.

It is more usual to create a sub-directory (named simply js) for all your JavaScript files. Even if there is only one, it’s a good habit to get into.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.