I have a for loop function, that loop through an array of objects. What I want is that the output is returned, to be clear the variable `outputHTML`, but the `return` function, execute the loop process, so it will return only one time. How can I repeat this process?

```js
for (var i = 0; i < data.media.length; i++) {

  if (data.media[i].image != undefined) {

    outputHTML = '<div class="image">';

    // for (var j = 0; j < data.media[i].image.length; j++) {
    // console.log(data.images[i]);

    // Extract filename
    var url = data.media[i].image.src;
    var filename = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
    // console.log(filename);

    outputHTML += '<img src="' + url + '" alt="' + filename + '" />';
    // $("body").append(outputHTML);

    // };

    outputHTML += '</div>';

    return outputHTML;

  } else {
    // If image doesn't exists return empty string
    return '';
  }

};
```