Javascript Array completeWith(lies, howMany)
Array.prototype.completeWith = function (lies, howMany) { var completed = this; var maxTries = 1000; while(completed.length < howMany && maxTries-- > 0) { completed = completed.concat(lies.shuffle()[0].toUpperCase()).unique(); }//www. j a v a2 s . c o m return completed; };