Q:

for?of loop

for x in range(6):
	print(x)
else:
	print("Finally finished!") 
7
for(int i = 0; i < some_number; i++){
  	//inside loop do whatever you want
}
7

var i = 2;
var len = cars.length;
var text = "";
for (; i < len; i++) { 
	// this is a comment
    text += cars[i] + "<br>";

 } 
8
//Let i be equal to 0; As long as i is smaller then 100; increment by 1;
for (let i = 0; i < 100; i++) {
 	//loop what you want
 }
3
const iterable = [10, 20, 30];

for (const value of iterable) {
  console.log(value);
}
// 10
// 20
// 30
0
// Unity for loop coroutine (repeat something every x seconds for x time)

Coroutine doThisCoroutine; // (Create a coroutine for stopping)
int duration = 5 // (Duration, whatever you want it to be)
float waitTime = 1 // Wait time to iterate in seconds, usually 1

void Awake(){
  
  DoThisCoroutine = StartCoroutine(DoThis()); // Start the coroutine
    
}
    
IEnumerator DoThis(){
  
  while (enabled){ // While the behavior is enabled,
  
    for (int x = 0; x < Duration; x++){ // From zero until 5 incrementing by 1...
    
      print("Doing This!"); // Do whatever...
  	
      yield return new WaitForSeconds(waitTime) // Every second.
  
  	}
  
  }

}
    
0
fruits = ['apple', 'orange', 'peach']

for fruit in fruits:
  print(fruit)
0

New to Communities?

Join the community