for each as a function code example
Example 1: jquery each
$( "li" ).each(function( index ) {
console.log( index + ": " + $( this ).text() );
});
Example 2: javascript foreach call specific value in array
run.addEventListener("click", function () {
people.forEach((element) => console.log(element.firstname));
}); // select a specific string in array