The advantage is that you have 1 file that effects multiple pages, this makes editing easier.
1. The extension has to be .js
2. you add src:
<script type="text/javascript" src="myExternal.js"></script>
3. make sure there is nothing between the <script> tags
The order that you attach scripts is important.
---------------------------------------------------
Trouble Shooting
Unfortunately the browsers interpret the scripts differently. The different browsers have tools to help you figure out errors.
Firefox:
Tools >> Error Console
Usually the information presented by the console is useless, but it gives you an idea of the area that is probably causing problems.
Firebug:
More usefull
Webdeveloper: (just for Firefox)
A toolbar extension that is really helpful, in particular with jQuery.
Safari:
Develop >>> Show Error Console
--------------------------REVIEW of the READING ASSIGNMENT-------------------------
Operators
Operators are Symbols that allow us to manipulate/modify data.
= assignment operator
(set to the value of)
Math Operators
+ - * /
Order of operations:
PEMDAS aka Please Excuse My Dear Aunt Sally
Parenthesis
Exponents
Multiplication
Division
Addition
Subtraction
M and D have the same weight
A and S have the same weight
so these are performed left to right
(PEMDAS will be on the test)
--------------
Combining Strings
Concatenation
+ the operator use to concatenate
(this is not the same as the mathematical operator + )
var lastName = "Fartyfatkins";
var firstName = "Hugo";
var theName = firstName + ' ' + lastName;
document.write(theName);
The Point this is to show that you should not have the ' ' (space) in the variable declaration.
var lastName = "Fartyfatkins "; BAD
Fixing - Automatic Type Conversion
Number(variable) +Number(variable2)
-------------------------------------
Order of operations:
PEMDAS aka Please Excuse My Dear Aunt Sally
Parenthesis
Exponents
Multiplication
Division
Addition
Subtraction
M and D have the same weight
A and S have the same weight
so these are performed left to right
(PEMDAS will be on the test)
--------------
Combining Strings
Concatenation
+ the operator use to concatenate
(this is not the same as the mathematical operator + )
var lastName = "Fartyfatkins";
var firstName = "Hugo";
var theName = firstName + ' ' + lastName;
document.write(theName);
The Point this is to show that you should not have the ' ' (space) in the variable declaration.
var lastName = "Fartyfatkins "; BAD
Fixing - Automatic Type Conversion
Number(variable) +Number(variable2)
Changing the Values in Variables
score = 0;
score = score + 3;
The point is that everything that happens on the right, gets dumped into the left.
-------------------------------------
No comments:
Post a Comment