- A : What is a script and how do I create one?
- B : How do computers fit in with the world around them?
- C : How do I write a script for a web page?
- B : How do computers fit in with the world around them?
** A script is a series of instructions that a computer can follow to achieve a goal. **
** 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.
- DEFINE THE GOAL
First, you need to define the task you want to achieve.
- DESIGN THE SCRIPT
To design a script you split the goal out into a series of tasks. This can be represented using a flowchart.
- CODE EACH STEP
Each of the steps needs to be written in a programming language that the compu ter understands.
An expression evaluates into a single value. there are two types of expressions.
- EXPRESSIONS THAT JUST ASSIGN A VALUE TO A VARIABLE
var color = 'beige';
- EXPRESSIONS THAT USE TWO OR MORE VALUES TO RETURN A SINGLE VALUE
var area = 3 * 2;
Expressions rely on things called operators; they allow programmers to create a single value from one or more values.
- ASSIGNMENT OPERATORS
Assign a value to a variable color = 'beige';
- ARITHMETIC OPERATOR
Perform basic math area = 3 * 2;
- STRING OPERATORS
Combine two strings greeting= 'Hi 1 + 'Mol ly';
- COMPARISON OPERATORS
Compare two values and return true or false buy = 3 > 5;
- LOGICAL OPERATORS
Combine expressions and return true or false buy= (5 > 3) && (2 < 4);
A JavaScript function is a block of code designed to perform a particular task.
** Functions allow you to group a set of related statements together that represent a single task. **
** Functions can take parameters (information required to do their job) and may return a value. **

