var courses = [ ["Amuse Bouche", 1], ["First Pair", 1,1], ["Second Pair", 2], ["Three Of A Kind", 1,1,1], ["Third Pair", 1,2,1], ["Full House", 2,2,1], ["Four Of A Kind", 1,1,1,1] ] function course(n) { console.log(n); n = n || 1; var ds = [ dish() ]; return ds.join(", "); } function dish(n){ var pcount = n || rand(2) + 1; var ps = []; while (pcount-- > 0) ps.push(product()); if (rand(100) < 90) { var d = ps.join(" and ") + " " + choice(preparations); } else { var d = ps.join(", "); } return d; } function product(){ var result; if (rand(100) > 99) { var technique = choice(techniques); if (technique[0] == '-') { result = choice(products) + technique + " " + choice(products); } else { result = technique + " " + choice(products) } } /* else if (rand(100) > 0) { result = choice(products) + " " + choice(products) } */ else { result = choice(products) } return result; }