What is a Script and how i can creat one?
A script is a series of instructions that a computer can follow to achieve a goal.
How to write 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.
Steps tp write a script :
-
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.
-
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 puzzl using a flowchart.
-
CODE EACH STEP : Each of the steps needs to be written in a programming language that the computer understands. In our case, this is JavaScript.
RULES FOR NAMING VARIABLES
Here are six rules you must always follow when giving a variable a name:
- The name must begin with a letter, dollar sign ($),or an underscore (_). It must not start with a number.
- The name can contain letters,numbers, dollar sign ($), or an underscore (_). Note that you must not use a dash(-) or a period (.) in a variable name.
- You cannot use keywords or reserved words.
- All variables are case sensitive .
- Use a name that describes the kind of information that the variable stores.
- If your variable name is made up of more than one word, use a capital letter for the first letter of every word after the first word.
Arrays
An array is a special type of variable. It doesn’tq just store one value; it stores a list of values.
- You create an array and give it a name just like you would any other variable (using the var keyword followed by the name of the array).
- Values in an array are accessed as if they are in a numbered list. It is important to know that the numbering of this list starts at zero (not one).
- An expression evaluates into (results in) a single value. Broadly speaking there are two types of expressions.