Array functionality

Template for writing a fiddle which can display a result, rather than having to output it to the console.

by Luis Perez

HTML

<pre id="output"></pre>

JavaScript

console.log = function() {
  var args = Array.prototype.slice.call(arguments, 0);
  document.getElementById('output').innerHTML += args.join(" ") + "\n";
}
'use strict'
// Short example. I use arrow functions for the array functions just because of preference for this one, for this example i don't think they offer pitfalls of scopes.                                                                                                   
// As many people have provided a solution but no real explanation already, feel that this could help you out.                                                                                                                                                           

function arrayIter(name_arr, obj_arr) {
  // Create a return array. As you've done in the code snippet                                                                                                                                                                                                         
  const ret_arr = []

  name_arr.forEach(current_element => {
    console.log(`Current Names element being checked ${current_element}`)

    /*                                                                                                                                                                                                                                                               
       Using a some function instead of a filter or forEach on this object array to short circuit the looping if your condition of finding the element is met.                                                                                                       
       If you view the console logs you'll see that it never goes past the element that matches. One caveat for this being if you want all elements that match                                                                                                       
       i.e. multiple franks, then you'd change it to a forEach to...