Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper functions... #87

Open
njsfield opened this issue Nov 14, 2016 · 0 comments
Open

Helper functions... #87

njsfield opened this issue Nov 14, 2016 · 0 comments

Comments

@njsfield
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant