NodeJS return data from for() function

This might be a very basic question but I’ve never done it and I can’t
make it so far, so I’m gonna asking it here!

I have a function in separate js file and it supposed to return messages from for loop data but not sure where the return has to go!

this is my code:

function test(x,y) {
    for(let i in y) {
        if(y[i].value == 'x') {
            return bot.message(y[i]);
        }
        sleep(1500);
    }
}

this doesn’t return anything.

So what I’m trying to do here is to send multiple messages from my loop and put 1.5 seconds sleep between each message.

What did I do wrong?