JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods

FOR LOOPS IN JAVASCRIPT

A for loop in javascript executes a block of code between the curly braces a specified number of times. The condition is evaluated first before the block of code between the curly braces can execute.

The general format is:

for(starting mark; condition; increment)

{
execute this code;
}

Example:

for(i=1; i < 6 ; i++)
{
document.write("Bart Simpson was here.<br>");
}

Our starting mark will assign our variable i to 1 ie. we want to start with i=1. We want to stop when i is less than 6 ie. i must be no more than 5. The above code will output Bart Simpson was here. five times and only stop executing when i is equal to 6.

Home | Privacy Policy | Terms Of Use | Contact Us