1

I just started using processing, and coding in general so I have no idea what anything stands for. However, I always see people using "i" in their codes, I don't really know what it stands for, so please how and when can I use "i"?

I tried searching for it online, yet I haven't found anything really helpful.

for(let i = 0; i < 10; i++)

sali khzuz
  • 11
  • 1

1 Answers1

1

Very elementary, it is a variable that can hold a value.

for(let i = 0; i < 10; i++)

above line is for loop that has three parts

initialization, condition, incrementation

so "i" is a variable that is initialized to zero and will run upto i = 9 and fails on 10.

after every execution of the loop body, i increments with 1 .. so it will be 0,1,2,....9 and then loop ends

you can take any variable name, i is not mandatory, it is a shorthand of index so people use it. Let say you take xyz as variable name then, for (let xyz=0; xyz <10; xyz++) { // code statements }

Bilal Siddiqui
  • 3,579
  • 1
  • 13
  • 20