Scratching The Surface Of Programming ( Part Two)

Scratching The Surface Of Programming (Part 2 )

This article is part two of the “Scratching The Surface Of Programming” series. In part one, we talked about what is actually programming is, what languages should I pick? And the differences between those languages . In part two, We want to get our hands dirty.

But, what a good language to do that?

We want a language that is friendly with beginners but not just a beginner language. We need it to be real, popular and relevant.


We will focus on learning JavaScript as a standalone language. JavaScript is a good language to start with, easy to explain programming concept with it and we can get started without installing anything on any platform.

Actually, while it’s a programming language you’ll also here refer to it as scripting languages, this is a description you hear not for any languages but those with script in the end of their names like ActionScript, AppleScript, and of course our language JavaScript.

It’s popular, a great language and an important because it is the language of the web browser and the only one that can deal with if you want to manipulate web pages.

But, it doesn’t matter if you use Chrome browser or Firefox or Safari they all have the JavaScript engine, it’s not the most powerful or the most flexible language out there but JavaScript invented for that reason.

So you are forced to use JavaScript to start to deal with the browser, and it’s built on some good ideas and a few very bad once, some of this very good ideas include Functions, loose typing, dynamic objects, Literal notation object and it’s an interpreted language as we noted in the last article, Don’t let these words confuse you we will go throw them all.

So let’s get hands on JavaScript

Well, we know it’s interpreted scripting language, and that is going to make it easier to experiment with because we don’t have to worry about creating files full of machine code. But, on the other hand, we can’t just write some JavaScript and have it magically run bu itself.

We are going to create our program that will run inside another program and it’s not unusual to have multiple levels of this in programming. Think about it this way, we have a computer and it going to run an operating system, within the operating system we are going to be opening and run a web browser, the web browser itself is going to run a web page and that web page is going to run and some interpreted JavaScript.

Now, if this seems like just too many levels deep, realize we always have most of this going on anyway. And we already have the computer, we already have the operating system, we already have the web browser. What we need to do is create the last two pieces.

We need to create the webpage that will open up in the web browser and the webpage will be the container that’s going to take care of interpreting and running the JavaScript that we’re going to write. So the first thing that we need to do is have a webpage.

Now, we don’t need to worry here about websites. We just need a single simple webpage. An HTML file whose only reason for existence is so we can point it to our JavaScript and say “go and do this.

First, you need to open your Text Editor and make two new files: index.html and script.js , in HTML file, write that code, don’t worry just write it.

This first file I’ve called index.html It doesn’t matter what the first part of the name is, but we’re using the .html and .js file extensions in lowercase, when we double-click it, it will open up in the default web browser, whether that’s Firefox, Safari, Internet Explorer, or anything else. As you can see here, it’s a very simple HTML page indeed. I also have a file in the js folder called script.js.

In the script.js file, you can write your JavaScript code, and double-click at index.html to open it in the browser then the JavaScript code will run immediately.

But what code?

Computer programs are all about input and output, click the button, move the mouse or even wave your hand in the air. It’s kind of inputs and the outputs could change what’s display on the screen.

The different languages favor different kinds of inputs and outputs, JavaScript is all about the webpage and kind of output that will deal with it, it might be an Alert box.

Open up the script.js file that found in the setup folder we made in your TextEditor and type:

var name = prompt(“what is your name?”);
alert(“Hello, ” + name);

Save the file and double click on index.html file, the web browser will load immediately and run that JavaScript file, and indeed what we get is a prompt asking about your name and giving a place to put your name in it, if you typed your name and click OK there is an alert box will show with your name in it.

Very simple code, but what is actually doing here?

The first statement is doing two things, it using the JavaScript prompt command to ask for a name and then it’s going to store that name in a variable aka var in JavaScript, this is a bucket that can hold some data in it. If we don’t tell our program to remember it we won’t able to use it on the next line.

The next line of code is going to combine the HELLO, with whatever you typed in prompt box, using this plus sign to combine this two parts of the message, and then pop it up in Alert Box.

So, var is the word to declare a variable, prompt() is the way to ask user to put some inputs, alert() is the initial way to show some outputs and every statement most close with semicolon (;)

In the next article, we will talk about Variables and Data types, it will be an introduction to what variables means, working with Numbers and Operators, using Characters and Strings and what is it whiteSpace and comments mean in programming languages.

Please ❤ and Share

Thanks for reading this! Hopefully, these few points make programming less confusing experience. If not, I’m happy to clear up any questions (or correct any errors you find in here)

I want to help as many people as possible. You can help me by hitting the little green ❤ and also by sharing this article on social media.