Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 2.19 KB

File metadata and controls

57 lines (42 loc) · 2.19 KB

THE ABC OF PROGRAMMING

  • 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?

** 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.

  1. DEFINE THE GOAL

First, you need to define the task you want to achieve.

  1. DESIGN THE SCRIPT

To design a script you split the goal out into a series of tasks. This can be represented using a flowchart.

  1. CODE EACH STEP

Each of the steps needs to be written in a programming language that the compu ter understands.

EXPRESSIONS

An expression evaluates into a single value. there are two types of expressions.

  1. EXPRESSIONS THAT JUST ASSIGN A VALUE TO A VARIABLE

var color = 'beige';

  1. EXPRESSIONS THAT USE TWO OR MORE VALUES TO RETURN A SINGLE VALUE

var area = 3 * 2;

OPERATORS

Expressions rely on things called operators; they allow programmers to create a single value from one or more values.

  1. ASSIGNMENT OPERATORS

Assign a value to a variable color = 'beige';

  1. ARITHMETIC OPERATOR

Perform basic math area = 3 * 2;

  1. STRING OPERATORS

Combine two strings greeting= 'Hi 1 + 'Mol ly';

  1. COMPARISON OPERATORS

Compare two values and return true or false buy = 3 > 5;

  1. LOGICAL OPERATORS

Combine expressions and return true or false buy= (5 > 3) && (2 < 4);

WHAT IS A FUNCTION?

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. **

Functions1 Functions2