reading-notes


Project maintained by Osamamomani1 Hosted on GitHub Pages — Theme by mattgraham

Dynamic web pages with JavaScript

github This is where we can change how the page behaves, adding interactivity. We will aim to keep as much of our JavaScript as possible in separate files.

JavaScript in the HTML

-You may see JavaScript in the HTML between opening tags

-The HTML

### it is better to put scripts in their own files for JavaScript Keeping it separate means that the page still works if the user cannot load or run the JavaScript.

Basic JavaScript Instructions

A script is a series of instructions that a computer can follow one-by-one. Each individual instruction or step is known as a statement. Statements should end with a semicolon.

You should write comments to explain what your code does. They help make your code easier to read and understand. This can help you and others who read your code.

Variables

A script will have to temporarily store the bits of information it needs to do its job. It can store this data in variables.

width x height = area

DATA TYPES

JavaScript distinguishes between numbers, strings, and true or false values known as a BOOLEAN

** you can use variables to store STRING or BOOLEAN . **

RULES FOR NAMING Variables

1)The name must begin with a letter, dollar sign ($),or an underscore (_). It must not start with a numbe

2)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.

3) You cannot use keywords or reserved words. Keywords are special words that tell the interpreter to do something. For example, var is a keyword used to declare a variable. Reserved words are ones that may be used in a future version of JavaScript.

4)All variables are case sensitive, so score and Score would be different variable names, but it is bad practice to create two variables that have the same name using different cases.

5)Use a name that describes the kind of information that the variable stores. For example, fi rstName might be used to store a person’s first name, l astNarne for their last name, and age for their age.

6)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. For example, f i rstName rather than fi rstnarne (this is referred to as camel case). You can also use an underscore between each word (you cannot use a dash).