JAVASCRIPT HELPS

ACCESS CONTENT

MODIFY CONTENT

PROGRAM RULES

You can specify a set of steps for the browser to follow (like a recipe), which allows it to access or change the content of a page. For example:

REACT TO EVENTS

You can specify that a script should run

when a specific event has occurred. For example, it could be run when:

Access the content of the page

Modify the content of the page Program rules or instructions the browser can follow React to events triggered by the user or browser

  1. . The script is triggered when the button is clicked.
  2. It collects the name entered into the form field.
  3. It checks that the user has entered a value.
  4. If the user has not entered anything, a message will appear telling them to enter a name.
  5. If a name has been entered, calculate the cost of the sign by multiplying the number of letters by the cost per letter.
  6. Show how much the plaque costs.

An expression evaluates into (results in) a single value. Broadly speaking

there are two types of expressions.

EXPRESSIONS THAT JUST ASSIGN A

VALUE TO A VARIABLE

EXPRESSIONS THAT USE TWO OR

MORE VALUES TO RETURN A SINGLE VALUE

Expressions rely on things called operators; they allow programmers to

create a single value from one or more values.

JavaScript contains the following mathematical

operators, which you can use with numbers. You may remember some from math class.

There is just one string operator: the+ symbol.

It is used to join the strings on either side of it.


Functions let you group a series of statements together to perform a

specific task. If different parts of a script repeat the same task, you can reuse the function (rather than repeating the same set of statements).

Having declared the function, you can then execute all of the statements between its curly brances with just one line of code. This is known as calling the function.

Sometimes a function needs specific information to perform its task. In such cases, when you declare the function you give it parameters. Inside the function, the parameters act like variables.

When you call a function that has paramateres, you specify the values it should use in parentheses that follow its name. The values are called arguemnts, and they can be provided as alues or as variables.

Some functions return information to the code theat called them. for example, when they perform a calculation, they return the result.