Javascript Array hasElementsStartingWith(currentWord, ignoreCase)
Array.prototype.hasElementsStartingWith = function (currentWord, ignoreCase) { for (var i = 0; i<this.length; i++) { var localWord = this[i].substring(0, currentWord.length); if ( localWord === currentWord || (ignoreCase && currentWord.toLowerCase() === localWord.toLowerCase()) ) return true;//www.ja va 2 s . co m } return false; }