While loop in while loop with function

Hello

I am working on a while loop within a while loop.

Is it possible to put the inner loop into a function? if yes, how?


while (...)
{
   // ...
   somefunction();
   // ...
}


function somefunction()
{
   while (...)
   {
      // ...
   }
}

Like this?