The for loop is the most compact form of looping and includes the following three important parts:

The loop initialization where we initialize our counter to a starting value. The initialization statement is executed before the loop begins.

The test statement which will test if the given condition is true or not. If condition is true then code given inside the loop will be executed otherwise loop will come out.

The iteration statement where you can increase or decrease your counter.

You can put all the three parts in a single line separated by a semicolon.

Syntax:

for (initialization; test condition; iteration statement){
 Statement(s) to be executed if test condition is true
}

Example:

<html>
<body>
<script type="text/javascript">
var count;
for(count = 0; count < 10; count++){
  document.write("Number : " + count );
  document.write("<br />"); }
</script>
</body>
</html>

This is the result:

 

 

Next

Chapter 15 - JavaScript While Loop

Recent Topics
Subject
Post Reply
Open
Recent
Module "MooZiiCart Search" of MooZiicart for search keywords of what we want
By prmindphp Mon 02 Dec 2019 11:31 am Board English Language
0
3213
Mon 02 Dec 2019 11:31 am By prmindphp View Topic Module "MooZiiCart Search" of MooZiicart for search keywords of what we want
Features Component MooZiiCart in Joomla for create website to sell products online
By prmindphp Sat 30 Nov 2019 7:00 pm Board English Language
2
4792
Wed 08 Apr 2020 6:51 pm By prmindphp View Topic Features Component MooZiiCart in Joomla for create website to sell products online
Business Analyst Training
By NehaaB Fri 29 Nov 2019 5:27 pm Board English Language
0
630
Fri 29 Nov 2019 5:27 pm By NehaaB View Topic Business Analyst Training
Program convert area
By prmindphp Wed 27 Nov 2019 11:26 am Board English Language
0
1178
Wed 27 Nov 2019 11:26 am By prmindphp View Topic Program convert area
Program exchange rate - Information form Bank of Thailand API
By prmindphp Tue 26 Nov 2019 2:34 pm Board English Language
0
1750
Tue 26 Nov 2019 2:34 pm By prmindphp View Topic Program exchange rate - Information form Bank of Thailand API
Tracking Thailand Post Program
By prmindphp Mon 25 Nov 2019 5:47 pm Board English Language
1
2572
Wed 02 Mar 2022 2:50 pm By ColleenCamacho59 View Topic Tracking Thailand Post Program
Square Root Calculate Program
By prmindphp Fri 22 Nov 2019 11:30 am Board English Language
0
1336
Fri 22 Nov 2019 11:30 am By prmindphp View Topic Square Root Calculate Program
The program calculates the mean, the variable, the standard deviation
By prmindphp Fri 22 Nov 2019 11:12 am Board English Language
0
1072
Fri 22 Nov 2019 11:12 am By prmindphp View Topic The program calculates the mean, the variable, the standard deviation
Introducing the new Mindphp.com Webboard system function (phpbb v.3.2)
By numtan5839 Tue 19 Nov 2019 6:06 pm Board English Language
0
964
Tue 19 Nov 2019 6:06 pm By numtan5839 View Topic Introducing the new Mindphp.com Webboard system function (phpbb v.3.2)
The most popular currency pairs in the Forex for new traders
By numtan5839 Mon 18 Nov 2019 5:32 pm Board English Language
1
2110
Fri 28 Jul 2023 6:27 pm By Okudama View Topic The most popular currency pairs in the Forex for new traders
BIG DATA and Hadoop
By Inglejyoti Mon 18 Nov 2019 4:03 pm Board English Language
0
1050
Mon 18 Nov 2019 4:03 pm By Inglejyoti View Topic BIG DATA and Hadoop
The most popular currency in the Forex
By numtan5839 Mon 18 Nov 2019 3:24 pm Board English Language
0
912
Mon 18 Nov 2019 3:24 pm By numtan5839 View Topic The most popular currency in the Forex
How to use the SQRT function in Excel
By numtan5839 Mon 18 Nov 2019 2:46 pm Board English Language
0
770
Mon 18 Nov 2019 2:46 pm By numtan5839 View Topic How to use the SQRT function in Excel
Deposit money into account with Thailand Post by Bank@post service
By numtan5839 Mon 18 Nov 2019 11:42 am Board English Language
0
1755
Mon 18 Nov 2019 11:42 am By numtan5839 View Topic Deposit money into account with Thailand Post by Bank@post service
Benefits and applications of moving averages
By numtan5839 Mon 18 Nov 2019 10:47 am Board English Language
0
625
Mon 18 Nov 2019 10:47 am By numtan5839 View Topic Benefits and applications of moving averages
Moving Average
By numtan5839 Sat 16 Nov 2019 2:45 pm Board English Language
0
795
Sat 16 Nov 2019 2:45 pm By numtan5839 View Topic Moving Average
weighted arithmetic mean
By numtan5839 Sat 16 Nov 2019 11:56 am Board English Language
0
765
Sat 16 Nov 2019 11:56 am By numtan5839 View Topic weighted arithmetic mean
Digital Marketing Training in Mumbai
By Kanchaan Fri 15 Nov 2019 6:10 pm Board English Language
4
2949
Mon 15 May 2023 4:46 pm By Reginaler View Topic Digital Marketing Training in Mumbai
Thailand Post appease e-commerce with ePacket service
By numtan5839 Fri 15 Nov 2019 5:59 pm Board English Language
1
2204
Mon 22 Nov 2021 1:31 am By mike0212 View Topic Thailand Post appease e-commerce with ePacket service
The character that precedes Tracking Number - Thailand Post Track & Trace
By numtan5839 Fri 15 Nov 2019 5:09 pm Board English Language
0
1366
Fri 15 Nov 2019 5:09 pm By numtan5839 View Topic The character that precedes Tracking Number -  Thailand Post Track & Trace