Free Assignments via E-mail

Enter your email address:

Subscribe the blog by your Email ID for the SMU MBA assignments updates.

Saturday, February 19, 2011

It is the answer of this question – “Explain with an example the for loop in Java Script? What are the other types of looping?” The question is prepared for SMU MI0032 MBA assignment. I have already shared a solved question of SMU MI0032 (Java and Web Design) assignment - Various Rules for Naming a Variable in Java.

A loop statement checks to see if some condition is true, say our condition is “Are there any invitations left?” and if that condition is true it will execute a chunk of code. Our code is this example would be stuff, lick, and seal the envelope. After the code is executed the condition is checked again, if it is true then the process begins again, if it is false, then the loop code stops execution and the script continues along.

Javascript for Loop:

The Javascript for loop resembles the for loop you might have seen in many other programming languages. It is used when you need to do a set of operations many times, with an increment of some kind after each run through the block of code.

Javascript for Loop Explained:

There are four important aspects of a Javascript for Loop:

1. The counter variable is something that is created and usually used only in the for loop to count how many times the for loop has looped.
2. The conditional statement that decides whether the for loop continues executing or not. This check usually includes the counter variable in some way.
3. The counter variable is incremented after every loop in the increment section of the for loop.
4. The code that is executed for each loop through the for loop.

This may seem strange, but 1-3 all occur on the same line of code. This is because the for loop is such a standardized programming practice that the designers felt they might as well save some space and clutter when creating the for loop.


New MBA Assignments

Opinions on MBA Assignments