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.
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.
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.
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.
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.
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);
Very simple code, but what is actually doing here?
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.
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.