#JavaScript JavaScript can be used in browsers to make websites more interactive,interesting ##A script is a series of instructions that acomputer can follow to achieve a goal (RECIPES,HANDBOOKS,MANUALS 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. First you have to
- DEFINE THE GOAL.
- DESIGN THE SCRIPT
- CODE EACH STEP Every step for every task shown in a flowchart needs to be written in a language the computer can understand and follow. To learn new langauge you have to larn
- Vocabulary: The words that computers understand
- Syntax: How you put those words together to create instructions computers can follow. To approach writing a script, break down your goal intoa series of tasks and then work out each step needed to complete that task (a flowchart can help).
- expressionss that just assign a value to a variable.
- expressionss 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.
There is just one string operator: the+ symbol.
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).
ex:"'' function updateMessage() { var el = document.getElementByld('message'}; el .textContent = msg; } ''' first you have to declaring the function and to declar itm we need to specific information to peform the task Expressions produce a value. They can be used where values are expected. If a function is placed where a browser expects to see an expression, (e.g., as an argument to a function), then it gets treated as an expression. The location where you declare a variable will affect where it can be used within your code. If you declare it within a function, it can only be used within that function. This is known as the variable's scope Global variables use more memory. The browser has to remember them for as long as the web page using them is loaded. Local variables are only remembered during the period of time that a function is being executed.