Loop a Function a Random Number of Times

How can I loop a function a random number of times?

// C#
randnumb = Random.Range (1,10)
for (int i = 0; i < randnumb; i++)
// i don’t actually know javascript so i’m guessing it will be one of these two
randnumb = Random.Range (1,10)
for (i=0;i < randnumb; i += 1)
//or
randnumb = Random.Range (1,10)
for (var i=0; i < randnumb; i += 1)

You didn’t specify, so I’ll give you a C# example of how to use a Coroutine to do this.

using UnityEngine;
using System.Collections;

public class LoopTest : MonoBehaviour 
{
	int loops;
	int count = 0;
	
	IEnumerator Start()
	{
		loops = Random.Range (5, 25);
		while(true)
		{
			count++;
			print (count+" of "+loops+"loops completed.");
			if(count == loops)
			{
				print ("Loop finished.");
				StopAllCoroutines();
			}
			yield return new WaitForSeconds(0.5f);
		}
	}
}