JSFiddle - React, Tailwind, and code Playground

HTML

<div id="foo"></div>

CSS

#foo {
    margin: 20px;
    padding: 20px;
    background: #f5f5f5;
    display: inline-block;
}

JavaScript

// Array
var bar = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

// Generic function
function loopTest(exit) {
    // jQuery each
    $.each(bar, function (i, o) {
        // Append result to foo div
        $("#foo").append(o + "<br />");
        // If exit is passed, and i is 4, return false
        if (exit && i == 4) {
            return false;
        }
    });
}

// Without exit
loopTest();

// Create a seperator for visual
 $("#foo").append("<br />---<br /><br />");

// With exit
loopTest(true);