Skip to content

Instantly share code, notes, and snippets.

@neftaly
Last active August 29, 2015 14:11
Show Gist options
  • Save neftaly/f74bb26a9704e2fb5242 to your computer and use it in GitHub Desktop.
Save neftaly/f74bb26a9704e2fb5242 to your computer and use it in GitHub Desktop.
PlayingArts.com card ripper
function cardimg (card) {
return "<img "
+ "src='http://playingarts.com/images/cards-big/"
+ card.suite + "-"
+ card.name + ".jpg' "
+ "style='width: 25%; display: block; float: left; '>";
}
function map (suites, names) {
output = [];
names.map(function (name) {
suites.map(function (suite) {
output.push({ "suite": suite, "name": name });
});
});
return output;
}
function draw (card) {
document.write(cardimg(card));
}
var suites = ["c","d","h","s"];
var names = [2,3,4,5,6,7,8,9,10,"j","q","k","a"];
map(suites, names).forEach(draw);
map(["joker"], [1,2]).forEach(draw);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment