From the course: Coding for Visual Learners: Learning JavaScript from Scratch
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
For Loop - JavaScript Tutorial
From the course: Coding for Visual Learners: Learning JavaScript from Scratch
For Loop
- [Instructor] One thing that computers are great at is repetitions. Imagine having to create thousand shapes on screen at different parameters. It will take us an unreasonable amount of time to do so with our current programming knowledge. For these kinds of cases, where we want to repeat our code as it is, or with some variations, we can leverage a programing structure called Loops. A Loop allows us to execute a block of codes over and over again. We are already familiar with the idea of a Loop in p5.js. If you think about it, the draw function is a continuous Loop that gets executed over and over again, until we exit the p5.js program. In this chapter, we will learn how to build this kind of a Loop ourselves. There are a couple of different kinds of Loop structures in JavaScript, but a for Loop is by far the most popular. It allows us to repeat an operation for a given amount of times. A for Loop has four parts.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.