how to make a for loop code example
Example 1: for loop
for (let i = 0; i < array.length; i++) {
}
Example 2: for loop
for(int i = 0; i < some_number; i++){
}
Example 3: for loop
for i in range (some_number):
#code goes here
Example 4: for loops
MyString = ""
for i in range(5):
MyString += "hi"
print(MyString)
Example 5: for loop
fruits = ['apple', 'orange', 'peach']
for fruit in fruits:
print(fruit)
Example 6: for loop
Coroutine doThisCoroutine;
int duration = 5
float waitTime = 1
void Awake(){
DoThisCoroutine = StartCoroutine(DoThis());
}
IEnumerator DoThis(){
while (enabled){
for (int x = 0; x < Duration; x++){
print("Doing This!");
yield return new WaitForSeconds(waitTime)
}
}
}