jQuery Map Example

https://modernweb.com/5-things-you-should-stop-doing-with-jquery/

by J. Albert Bowden

HTML

<script src="https://getfirebug.com/firebug-lite.js"></script>

JavaScript

(function($) {

  var allStarCast = [{
    firstName: "Zack",
    lastName: "Morris"
  }, {
    firstName: "Kelly",
    lastName: "Kapowski"
  }, {
    firstName: "Lisa",
    lastName: "Turtle"
  }, {
    firstName: "Screech",
    lastName: "Powers"
  }, {
    firstName: "A.C.",
    lastName: "Slater"
  }, {
    firstName: "Jessie",
    lastName: "Spano"
  }, {
    firstName: "Richard",
    lastName: "Belding"
  }]

  // iterate through the cast and find zack and kelly

  var worldsCutestCouple = $.map(allStarCast, function(actor) {
    if (actor.firstName === "Zack" || actor.firstName === "Kelly") {
      return actor;
    }
  });

  console.log(worldsCutestCouple);

}(jQuery));