JavaScript files end with the .js file extension.
Example
Filename: Script.js
JavaScript files can be created in three different ways in Spaces.
1. Starting with a blank template. This will create a JavaScript file ready to use.
2. Upload your own .js file
3. Create a new file in the File overview and change its name to something, ending with .js
You can read about changing file names in this related article: How do I rename files and folders?
You have to enter code into the file to make it functional.