Hi. I have a question about return statement in greetAliens task

I have a question about how things are returned.
Instead of console.log() I wanted to return Oh powerful…`, but then only

Oh powerful Blorgous…

is outputted.

Nothing more. Also, I wanted to use this:

phrase = `Oh powerful...`

and then return it, but only

Oh powerful SpaceKing…

is outputted.
But when I just console.log() every name, it works. Why?

const greetAliens = (arr) => {
    let phrase = '';
    for (let i = 0; i < arr.length; i++) {
        /*
        a good thing to notice:
        if we used just return `Oh powerful...`, then only `Oh powerful Blorgous...` would be returned.
        if we used phrase = `Oh powerful...` and then returned it, only 'Oh powerful SpaceKing..` would be returned.
         */
        console.log(`Oh powerful ${arr[i]}, we humans offer our unconditional surrender!`);
    }
}
greetAliens(["Blorgous", "Glamyx", "Wegord", "SpaceKing"]);
/*
Oh powerful Blorgous, we humans offer our unconditional surrender!
Oh powerful Glamyx, we humans offer our unconditional surrender!
Oh powerful Wegord, we humans offer our unconditional surrender!
Oh powerful SpaceKing, we humans offer our unconditional surrender!

*/

Hey!

An important thing to note about return is that it not only returns a value, but it also ends the execution of the function. This means that for your code, the loop runs once, returns the string Oh powerful Blorgous…, which is then printed out and the function is then ended as a return has been reached, so there’s never an opportunity for the loop to run a second time and print the next message.

Hope that helps!