How to Write Source Code and Work With Loops in JavaScript


show more Iteration is the programming buzzword for a loop, which is an essential part of programming. In this video, Simon explains how to create, customize and stop a loop. JavaScript is used as the basis for this lesson, but the skills are applicable to many programming languages and will help lay the ground work for setting different loop types. show less
please wait ...

Introduction to iteration

So let's talk about iteration. This is the programming buzzword for a loop. And here's the idea. You start writing some code. A few statements that deal with, say, looking in all the MP3 files in a folder or changing the position of an image on the screen. So we write some statements to do it once. Then we figure out we need to do it again. So we write them again and again and again. All these can get pretty tedious and rather than write it out several times or even several thousand times, I'd like to be able to write my statements once and then just say "Repeat this." Repeat it 5 times or repeat it 5,000 times, or keep repeating until told to stop, or go through all the fields on a web page or go through every MP3 file in a folder.

So we might repeat two statements, we might repeat a dozen, we might repeat a hundred. And this is what we do by creating loops and you'll also hear this called iteration. Now creating loops is actually easy. The main issue with any loop is ...

Introduction to iteration
Video duration: 4m 28s 4h 47m Beginner

Viewers:

Iteration is the programming buzzword for a loop, which is an essential part of programming. In this video, Simon explains how to create, customize and stop a loop. JavaScript is used as the basis for this lesson, but the skills are applicable to many programming languages and will help lay the ground work for setting different loop types.

Subjects:
Developer Web
Author:
please wait ...