Generate messages with for Loops

Hi Forum,

my msg.payload has an array and i want to run a for-loop times the size of the array length. Every time the loop ends the function should return a message. Is that possible?

I tried the following but this is not working, of course

for (let i = 0 ; i<msg.payload.length; i++){
    return msg;
}