the-ABC-of-programming

View the Project on GitHub

The ABC of programming

What is a Script and how do I create one?

A script is a series of instructions that a computer can follow to achieve a goal. You could compare scripts to any of the following:

1- Recipes

2- Handbooks

3- Manuals

WRITING A SCRIPT

To write a script, you need to first state your goal and then list the tasks that need to be completed in order to achieve it.

Start with the big picture of what you want to achieve, and break that down into smaller steps.

1- DEFINE THE GOAL

First, you need to define the task you want to achieve. You can think of this as a puzzle for the computer to solve.

2- DESIGN THE SCRIPT

To design a script you split the goal out into a series of tasks that are going to be involved in solving this puzzle. This can be represented using a flowchart. You can then write down individual steps that the computer needs to perform in order to complete each individual task (and any information it needs to perform the task), rather like writing a recipe that it can follow.

3- CODE EACH STEP

Each of the steps needs to be written in a programming language that the compu ter understands. In our case, this is JavaScript.

Tasks

Once you know the goal of your script, you can work out the individual tasks needed to achieve it. This high-level view of the tasks can be represnted using flowchart.

Flowchart

Steps

Each individual task may be broken down into a sequence of steps. When ypu are ready to code the script,these steps can then be translated into individual lines of code.

steps

How do computers fit in with the world around them?

How a briwser sees a web page

In order to understand how you can change the content of an HTML page using JavaScript, you need to know how a browser interprets the HTML code and applies styling to it.

1: RECEIVE A PAGE AS HTML CODE
2: CREATE A MODEL OF THE PAGE AND STORE IT IN MEMORY
3: USE A RENDERING ENGINE TO SHOW THE PAGE ON SCREEN

All major browsers use a JavaScript interpreter to translate your instructions (in JavaScript) into instructions the computer can follow.