Javascript Conditional Statement and Function
Javascript Conditional Statement and Function
function
functionname
(var1,var2,var3…,varN) functionname is the name of the
function. var1,var2,…, varn are
{
parameters
//place your codes here
}
What is Loop?
• There are times when you want a block code repeated over and over again until a
certain condition is satisfied.
• JavaScript Loops
• For Loop – It loops through a block of code within a specified number of times.
• While Loop – It loops through a block of code until the condition is satisfied.
• Do While Loop - It is like while loop; however, it will execute the set of codes at
least once.
• For in loop- It loops through the elements of an array.
Different Kinds of Loops
Syntax
for (key in object) {
// code block to be executed
}
The Break Statement
You have already seen the break statement used in
an earlier chapter of this tutorial. It was used to
"jump out" of a switch() statement.
The break statement can also be used to jump out of
a loop: