Javascript Array isCharPresent(charSearch)
Array.prototype.isCharPresent = function(charSearch) { var arr = this; var result = []; var testingStr = ''; if (charSearch.length > 1) { return "You're searching for more than one char"; }/* ww w . j a va 2 s . c o m*/ for (var i = 0; i < this.length; i++) { if (arr[i].indexOf(charSearch) === -1) { continue; } else { result.push(arr[i]); } } return result; //search through eachChar } console.log(["alphabet", "oxygen", "result"].isCharPresent('a')); console.log(["alphabet", "oxygen", "result"].isCharPresent('al')); console.log(["alphabet", "oxygen", "result"].isCharPresent('e'));