If you’re reading this I’m going to assume you’re interested in Javascript. You’ve heard so much of arguably the most controversial programming language currently in use by software programmers. Javascript is called the engine of the web by many, it is the language that adds dynamism to web pages in the same way that CSS (Cascading Style Sheets) style the web.
Today, I am going to help you create your first Javascript programme. By the time we’re done, you will have created a programme that will print “Hello World” to the console of a web browser or other platforms that can read and support Javascript programming language. As an added bonus we will also include the feature of having it alert “Hello World” in a web browser. From here you can begin your journey into the exciting world of Javascript and software engineering by extension.
I am not going to be dwelling on the specifics of code editors (code editors are basically tools used to write and debug code). You can use any code editor for this project, I personally recommend VS Code.
Step 1: You should create a folder and call name it (or not), keep the folder somewhere you can easily find it like your desktop or your documents folder.
Step 2: Open your code editor and use it to navigate (by choosing to open that folder using your code editor) to your new (empty) folder.
Step 3: Create a new file, you can name it anything you like as long as it ends with the “.js” suffix.
The .js suffix communicates to the machine or any platform that can read Javascript code that the file in question has Javascript code in it. It’s the same way pdf documents end with “.pdf” and word document files end with “.doc”.
Step 4: Now that you’re in your new (empty) Javascript file, type
Console.log(“Hello World”);
Step 5: Press the “Enter” key (on your keyboard) which takes you to a new line, and type
alert(“Hello World”);
Step 6: Save the changes you have made and open it on a browser or platform that can read this kind of code, you can open your Google Chrome browser and type press Ctrl+Shift+J then copy all the code you wrote in your .js file and paste it into the console you just opened in your browser.
Step 7: Press the enter key and it’ll run.