function getRandomLetter(bag){ for(var k=0;k<1000;k++){ var index = Math.floor(Math.random()*N); if(bag[index] !== null)return index; } } function removeFromBag(bag, index){ bag[index] = null; } function checkSolution(aTarget,aTrial){ var ncorrect = 0; if(aTarget.length === aTrial.length){ for(var i = 0;i