function validateInput(query) {
return query.replace(/[^a-z]/gi, '');
}
function makeRegExp(input) {
return new RegExp('^' + input, 'i');
}
function match(list, regex) {
return list.filter(function(word) { return regex.test(word); });
}
These are great! :) We used methods like these throughout our project but didn't think to wrap them in functions, nice :)
Perhaps put these into a 'helpers.js' file and require it in to files that need it?
These are great! :) We used methods like these throughout our project but didn't think to wrap them in functions, nice :)
Perhaps put these into a 'helpers.js' file and require it in to files that need it?