Lost Password?

  #1 (permalink)  
Old 12-06-2006, 03:11 PM
TcM's Avatar   
TcM TcM is offline
Moderator
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 7,232
Rep Power: 66
TcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud of
Default JavaScript:Tutorial, Loops

Introduction:-
In this tutorial I will show you the two types of loops there are in JavaScript.

Explanation:-
You might say where is the code? He is already explaining without the code?
Well this time I think that its better if the Explanation comes before the Code

There are 2 types of loops:-
  • For Loops
  • While Loops

For Loops:-
The For Loops are used in this way

Code:
for (something)
{
do something else
}
While Loops:-
The While Loops are used in this way:-

Code:
while (something)
{
Do something else
}
Solution:-
Now that you had an idea of the basic usage of the loops here are some practical codes:-

For Loops:-

Code:
<SCRIPT LANGUAGE="JavaScript">
var lp=1;
for (lp=0;lp<15;lp++)
{
document.write ("For Loop "+lp+"<BR>");
}
</SCRIPT>
Note: lp is a variable, and until that variable has reached the value of 14 (<15) the loop will go on

While Loops:-

Code:
<SCRIPT LANGUAGE="JavaScript">
var lp=0;
while (lp<15)
{
document.write ("While Loop "+lp+"<BR>");
lp++;
}
</SCRIPT>
Note: lp is a variable, and while that variable is <15 the loop will go on

A Preview:-
None

Conclusion:-
As Always Feedback is welcome! In the next tutorial I will tell you how to exit from the loop. I don't think that this needs any source code..

Last edited by TcM; 12-06-2006 at 03:14 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 12-07-2006, 08:52 PM
Ronin Ronin is offline
Programming Professional
 
Join Date: Apr 2006
Posts: 299
Rep Power: 10
Ronin is on a distinguished road
Default

Nice tutorial. I need to learn JavaScript sooner or later and these (the ones that you've been posting) will help a lot!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-08-2006, 04:15 AM
TcM's Avatar   
TcM TcM is offline
Moderator
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 7,232
Rep Power: 66
TcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud of
Default

Quote:
Originally Posted by Ronin View Post
Nice tutorial. I need to learn JavaScript sooner or later and these (the ones that you've been posting) will help a lot!
I'm happy these helped you I will be posting more and more.. be sure to see my next tutorial ( will be posted very soon ) on how to break out of a loop...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-13-2006, 08:35 AM
castanza88 castanza88 is offline
Newbie
 
Join Date: Dec 2006
Posts: 5
Rep Power: 0
castanza88 is on a distinguished road
Default Javascript tutorials

good breakdown of code, and examples...wish more people did that...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-13-2006, 08:53 AM
TcM's Avatar   
TcM TcM is offline
Moderator
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 7,232
Rep Power: 66
TcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud ofTcM has much to be proud of
Default

Quote:
Originally Posted by castanza88 View Post
good breakdown of code, and examples...wish more people did that...
Thanks... for your feedback
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript:Tutorial, Digital Clock TcM Javascript 10 06-06-2008 01:38 PM
MySQL Loops reachpradeep Database & Database Programming 0 03-04-2007 09:12 AM
JavaScript:Tutorial, Confirmation Box TcM Javascript 4 02-14-2007 08:25 AM
JavaScript:Tutorial, Break Out Of Loops TcM Javascript 0 12-08-2006 05:35 AM
Loops Sionofdarkness C and C++ 7 07-28-2006 07:53 PM


All times are GMT -5. The time now is 11:37 AM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 66%

Ads