Skip to content

Instantly share code, notes, and snippets.

@epk
Last active August 26, 2018 21:05
Show Gist options
  • Save epk/86f9e816bfc5524df35aa449e4383788 to your computer and use it in GitHub Desktop.
Save epk/86f9e816bfc5524df35aa449e4383788 to your computer and use it in GitHub Desktop.
autocomplete.js
function autocomplete(query) {
var answer = [];
mixmaxFeatures.forEach(function(feature){
let counter = 0;
query.toLowerCase().split(' ').forEach(function(word){
feature.toLowerCase().split(' ').forEach(function(featureWord){
if (featureWord.startsWith(word)){
counter++;
}
})
})
if (counter === query.split(' ').length){
answer.push(feature);
}
})
return answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment