Jump to content

I am learning web development, and my editor of choice is VS code, which worked phenomenal with python and HTML. But I just can't get it to pick up JS. I have installed a few extensions and installed node.js, but it didn't work. please tell me what I should do.

image.png.c6a11ff9150177165373fd239e53275e.png

Link to comment
https://linustechtips.com/topic/1609281-how-do-i-install-java-in-vs-code/
Share on other sites

Link to post
Share on other sites

JavaScript and Java are not the same.

 

Do you mean you want to install a plugin to do syntax highlighting or what do you mean by it's not picking up JS?

Remember to either quote or @mention others, so they are notified of your reply

Link to post
Share on other sites

Just now, Eigenvektor said:

JavaScript and Java are not the same.

 

Do you mean you want to install a plugin to do syntax highlighting or what do you mean by it's not picking up JS?

I mean, like for HTML or python, it color codes everything to look nice, and, more importantly than that, it autocompletes the lines and finds errors. Its not doing that for JS

Link to post
Share on other sites

3 minutes ago, GT710 Connoisseur said:

I mean, like for HTML or python, it color codes everything to look nice, and, more importantly than that, it autocompletes the lines and finds errors. Its not doing that for JS

We're using "Prettier - Code formatter" at work, it supports JavaScript, TypeScript, CSS, SCSS, HTML and a bunch of other web related languages. Also, which plugin(s) have you tried?

 

We're also using ESLint to do some error checking.

Remember to either quote or @mention others, so they are notified of your reply

Link to post
Share on other sites

18 minutes ago, Eigenvektor said:

We're using "Prettier - Code formatter" at work, it supports JavaScript, TypeScript, CSS, SCSS, HTML and a bunch of other web related languages. Also, which plugin(s) have you tried?

 

We're also using ESLint to do some error checking.

OK. thank you very much. The problem was just VS code being dumb. The plugins I have currently are- ESLint, Prettier code formatter and javascript code snippets. They work only in .js files, and not in HTML scripts. 

Link to post
Share on other sites

You made a function in JS, but you never called it. You have to call hlo(); after you define the function to make it run. Or cal it from within the HTML somewhere.

 

Also, you have the script defined in the head. You'll typically want it at the end of your HTML (right before your </html> tag at the bottom of the file. This is to make sure the DOM is loaded before the JS tries to reference it. The alternative is to use the defer param, if you want to put it in the head, which will defer loading it until the rest of the page loads.

 

You could also have it do it on page load, with something like this.

window.onload = function() {
  hlo();
};

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×