Using a for loop for dynamic objects

First understand the examples in the link I posted, then you just need to provide a function that returns the wardId.