So you want to code in JavaScript...

First, make sure you have Visual Studio Code installed.

Note - there is a difference between programming JS in the console (NodeJS) and the browser with HTML.

The basic Linux Dev Environment does not come with a JavaScript interpreter built-in. You can code in JS and run your code via the browser, but that's not as easy or intuitive.

NodeJS is a complicated system. There are many versions, an add-on package manager, etc. Let's keep it simple and just install your basic NodeJS:

{It's best to have all other programs closed before installing NodeJS and reboot when finished}

Windows & MacOS - Download and install the "LTS" version from here.

ChromeOS - From a terminal prompt: sudo apt -y install nodejs

You should now have NodeJS installed and be able to "run" (interpret) JavaScript files saved with the .js file extension.
Visual Studio Code will still not "run" JavaScript files. For that you need a VSCode Extension called "Code Runner"

See: VSCode Extensions