Skip to content

Instantly share code, notes, and snippets.

@sgnl
Created January 29, 2015 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgnl/8d713c4f5560e9cb1182 to your computer and use it in GitHub Desktop.
Save sgnl/8d713c4f5560e9cb1182 to your computer and use it in GitHub Desktop.
<!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>
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