Getting started with JaveScript and a real basic program
I’m currently following an online course on udemy.com which is teaching me JavaScript. I’ve decided to make some notes along the way to refer back to once all this stuff gets pushed out of my head again when I get back into robotics in September.
This post is about how to start up a new JavaScript project using Sublime text editor (3).
The first thing to do would be to create a new project folder somewhere on your computer and inside that folder, create two new txt files and rename them index.html and script.js respectively.
Next would be to open up the index.html file using sublime text editor and type “html” and then hit the “tab” key on the keyboard. This will create a blank html template for us to begin our project. Save the file.
Next would be to give the page a title, a H1 tag with a title and link the javascript file in the head as shown below.
Next step is to open the script.js file that we created earlier in our project folder and add the following line of code to test the “connection”.
Once done, ensuring both files have been saved, open up the index.html file in your browser to see what we’ve made.
The first thing that pops up is our prompt that we put in our js file and once that is closed the H1 tag showing out title is displayed.
That’s it. Now our js file is connected to our HTML document we can begin adding code to our script.js file.