Find more freelance jobs
|
<body> <script src="xxx.js"> </script> </body> </html> Remember to place the script exactly where you normally would write the script. Variables A variable is a "container" for information you want to store. A variable's value can change during the script. You can refer to a variable by name to see its value or to change its value. Rules for Variable names: · Variable names are case sensitive · They must begin with a letter or the underscore character Declaring Variables You can create a variable with the var statement: var strname = some value You can also create a variable without the var statement: strname = some value Assigning Values to Variables You assign a value to a variable like this: var strname = "Hege" Or like this: strname = "Hege" The variable name is on the left side of the expression and the value you want to assign to the variable is on the right. Now the variable "strname" has the value "Hege". Assignment Operators Operator Example Result = i = 5 i equals 5 += i += 5 i equals i + 5 -= i -= 5 i equals i - 5 *= i *= 5 i equals i * 5 |