Random Movement For NavMesh?

I’m giving my enemy idle movement, and currently I’ve gotten it to walk between a few set points. But the thing is, this is too linear and predictable for what I wish to achieve. I want it to move randomly by creating a point to move to that pops up on a random location somewhere on the map, and then create a new one once that one has been reached. While also making sure that it doesn’t try to walk to an area it cannot reach.
However I have no idea how to code this. I tried looking it up, but found nothing. There was one example that seemed to do what I wanted, but it was written in C#, and as a stubborn Javascript user that made it useless since I couldn’t translate it.

So does anyone know how this can be done? Making the AI create randomly placed walkable points to walk to, preferably also within a defined area so that I can also use this to make it search a smaller area after losing sight of the player?

This has what you need:

Excuse my poor Javascript translating abilities but the code in that link translated should be:

randomDirection : Vector3 = Random.insideUnitSphere * walkRadius;
randomDirection += transform.position;
hit : NavMeshHit;
NavMesh.SamplePosition(randomDirection,out hit, walkRadius, 1);
finalPosition : Vector3 = hit.position;

Where walkRadius is arbitrary value you set so the AI doesn’t pick a point and wander out into the abyss. Once you have the random point you can use it the same as you were when you had the AI moving between two points. Just have the script wait until the point is reached before it calculates a new place to walk to.