How would I get JS to ignore everything that is not a letter (e.g. abc...) without using regex.
Examples
match("abcdef","@C2D!") returns true
match("abcdef","CAfe") returns true
match("abcdef","CG") returns false
This is what I've done so far...
function match(string, pattern) {
string = string.toLowerCase();
pattern = pattern.toLowerCase();
for (var i = 0, l = string.length; i < l; ++i) {
if(pattern.indexOf(string[i]) === -1) return false;
}
return true;
}
alert(match("abcdef", "@C2D!"));
Fiddle here: http://jsfiddle.net/5UCwW/