Saturday, 29 June 2013

how to understand for loops in javascript

Authour:I will teach you courses online

C Language C++ Asp.net VB.net Oracle Hardware and Networking MCSE
Contact: Name: Shrinivas Mobileno:919703619391 E-mail: vas.shrinivas002@gmail.com
-----------------------------------------------------------------------------------------------------------
Few days back in summer we went to beach, I have collected few pebbles. I called my daughter given pebbles one by one.


I have given first one-1 pebble
She started counting 1pebb
Next given second one-1 pebb
She started counting 1+1 pebb=2 pebbles
Next given third one-1 pebb
She started counting 2+1 pebb=3 pebbles
Next given fourth one-1 pebb
She started counting 3+1=4 pebbles


This is foundation for FOR loop to understand.


var daughter;

for(daughter=1;daughter<=4;daughter++)
{
document.write(daughter);
}


how to understand program

var daughter:DECLARATION

DAUGHTER<=4 : FATHER IS CONDITION ,BECAUSE HE KNOWS HOW MANY PEBBLES IN HIS HAND.

DAUGHTER IS COUNTING: DAUGHTER++

var daughter;

for(daughter=1;daughter<=4;daughter++)
{
document.write(daughter);
}

for loop iteration:
first iteration  1 number->Because i have given 1 pebble-she started counting 1 pebble

second iteration 2 number->i have given another 1 pebble-she started counting 1+1=2 or[daughter++=2]

third iteration 3 number-> i have given another 1 pebble-she started counting 2+1=3 or[daughter++=3]

fourth iteration 4 number->i have given another 1 pebble-she started counting 3+1=4 or[daughter++=4]

------------------------------------------------------------------------------------------------------------
Next you can implement above methodology in your environment(c,c++,c#,java)






                 

No comments:

Post a Comment