Created
January 29, 2015 21:50
-
-
Save sgnl/8d713c4f5560e9cb1182 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/notenebovi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var groceryStore = { | |
Fruit: ["Apple", "Bananas", "Oranges"], | |
Milk: ["Low-Fat", "Skim", "Whole Milk"], | |
Candy: ["Goodbar", "Reese's pieces", "Sour Patch Kids"] | |
}; | |
function goTo(location, aisle, callback){ | |
for (var thisAisle in location) { | |
if (thisAisle === aisle) { | |
location[thisAisle].forEach(function(item){ | |
var result = callback(item); | |
if (result === true) { | |
console.log("I found the " + item + " " + aisle); | |
} | |
}); | |
} | |
} | |
} | |
goTo(groceryStore, "Milk", skimMilk); | |
function skimMilk () { | |
if (type === "Skim") { | |
return true; | |
} | |
return false; | |
} | |
function sourPatchKids() { | |
if (type === "Sour Patch Kids") { | |
return true; | |
} | |
return false; | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var groceryStore = { | |
Fruit: ["Apple", "Bananas", "Oranges"], | |
Milk: ["Low-Fat", "Skim", "Whole Milk"], | |
Candy: ["Goodbar", "Reese's pieces", "Sour Patch Kids"] | |
}; | |
function goTo(location, aisle, callback){ | |
for (var thisAisle in location) { | |
if (thisAisle === aisle) { | |
location[thisAisle].forEach(function(item){ | |
var result = callback(item); | |
if (result === true) { | |
console.log("I found the " + item + " " + aisle); | |
} | |
}); | |
} | |
} | |
} | |
goTo(groceryStore, "Milk", skimMilk); | |
function skimMilk () { | |
if (type === "Skim") { | |
return true; | |
} | |
return false; | |
} | |
function sourPatchKids() { | |
if (type === "Sour Patch Kids") { | |
return true; | |
} | |
return false; | |
}</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var groceryStore = { | |
Fruit: ["Apple", "Bananas", "Oranges"], | |
Milk: ["Low-Fat", "Skim", "Whole Milk"], | |
Candy: ["Goodbar", "Reese's pieces", "Sour Patch Kids"] | |
}; | |
function goTo(location, aisle, callback){ | |
for (var thisAisle in location) { | |
if (thisAisle === aisle) { | |
location[thisAisle].forEach(function(item){ | |
var result = callback(item); | |
if (result === true) { | |
console.log("I found the " + item + " " + aisle); | |
} | |
}); | |
} | |
} | |
} | |
goTo(groceryStore, "Milk", skimMilk); | |
function skimMilk () { | |
if (type === "Skim") { | |
return true; | |
} | |
return false; | |
} | |
function sourPatchKids() { | |
if (type === "Sour Patch Kids") { | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment