C5 W1A2 exercise 4 - set the index

I read this a few times but I still don’t understand what we are suppose to do with the idx and why. Can someone explain?

It’s a very long-winded way of saying that idx is j modulo the number of examples.

Because J will go beyond the # of examples, so we created idx to track which example we are on.

I got it now. Thank you.