There are 2 ways.
1. Apply directly in HTML using script tag.
2. Create a file that contains JS code. Then, save it in the same location as the HTML file or in a folder in that location. Then add that path in the src of script which should be either inside head or at the end of body of HTML.