Last active
August 29, 2015 14:24
-
-
Save riebschlager/f52e434fa8508bfceedb to your computer and use it in GitHub Desktop.
Three Little Pigs (Javascript Edition)
This file contains hidden or 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 pigs = [{ | |
name: 'Doug', | |
}, { | |
name: 'Larry' | |
}, { | |
name: 'Virgil' | |
}]; | |
var houses = { | |
straw: { | |
strength: 1 | |
}, | |
stick: { | |
strength: 2 | |
}, | |
brick: { | |
strength: Infinity | |
} | |
}; | |
pigs[0].house = houses.straw; | |
pigs[1].house = houses.stick; | |
pigs[2].house = houses.brick; | |
var wolf = { | |
name: 'Chuck', | |
strength: 3 | |
}; | |
for(var i = 0; i < pigs.length; i++) { | |
console.log('WOLF: Little Pig, Little Pig. Let me in'); | |
if(pigs[i].house.strength > wolf.strength) { | |
console.log('PIGS: No, no, not by the hair on my chinny chin chin.'); | |
} else { | |
console.log('PIGS: Oh crap.'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would gladly accept any pull requests :)