Introducing the for loop:

You can basically do the same thing a bunch of times. So imagine you can do something like render the same item over and over again, but with possible slight adjustments each time, and you can control the offset or how many repetitions this thing takes, that is basically what the for loop is.

What to do, and how many times to do it, you have three parenthesis that separate out the declaration of the interactive variable, the boolean condition for the loop, and then the operation for you look as well.

Why am I writing all of this? I literally coded by own for loop from scratch in C, this is a bit silly, but you basically just have it be a while look with a variable that you check at the end of each loop and increment in a manner, its fairly odd for sure, but pretty cool too:

Pasted image 20261108175526.png

So the for loop in the image of course basically sets up the variable i, and it is of value zero, and until i is less than 10, you run the code and increment i by one each time. You can also do things like moving i downward to iterate in reverse, or even in increments if you say want to draw something at an offset, its very nice overall.

You can also use outside variables in order to draw things that are the same throughout the for loop, or even something that would allow you to change the variable each time in order to draw something in a row or a line or whatever you would like really. Of course you can also have static hard coded values inside of a variable as well, although those do not hold their state every time throughout the for loop, although can change them using the iterator variable.

Pasted image 20261108180815.png

Combining Conditionals with For Loops

So you can obviously have things like nested loops over even some conditionals within of the for loops, or the other way around as well. You can do something like check to see if a certain number is even and then do something then, and if odd then do something else.

Since you can change things throughout the course of a loop, you can also in that case check to see what it is that you have changed, or has changed since the last loop, allowing you to have a bunch of different variation and creativity in your for loops, the guy doing this video is a dumbass


Arrays

Basically a variable that lets you store multiple different items in a single variable that you can access using an index. I know what an array is. Of course in Javascript they’re fucking retarded but that’s just because it’s javascript. You declare an array with something like a bracket and then you can list out the items, they are dynamic inside of javascript so you can add elements to them as far as I am aware as well, and they can support multiple different types as well.

Of course these are really great if you want something like millions of points of data or even a dynamic amount of data, instead of manually writing out millions of variables, you can use the array. They’re a very good data structure, as a matter of fact I am suprised but they even show some others:

Pasted image 20261109142013.png

These are all, I mean very very loosely, built up using arrays, although things like stacks and queues are better for direct arrays of course, and in almost every single language the index of an array starts at 0

Pasted image 20261109142339.png

The above is how you create the array and what not, and then the way in which you would go ahead and index it would be to use the square brackets at a given index, and you can change a value like this or just access it, if you go outside of the array bounds in most languages this is an error, javascript might be weird so it might just be undefined.