There are 3 ways to run and test these javascript files.
Method 1 (not preferred, but you can 🖕)
copy the code which you want to run, open any online javascript interpreter paste it and run.
Method 2 (you can give it a try 🙂)
create a html file inside that file create a <script/> tag and give reference to .js file which you want to run. Open that file in your browser... now you can see the output in your browser's console.
Method 3 (the only preferred way on planet earth 😎)
install NodeJs on your machine. Open your terminal (cmd) and type this command- node /path/to/file.js