Last active
August 26, 2018 21:05
-
-
Save epk/86f9e816bfc5524df35aa449e4383788 to your computer and use it in GitHub Desktop.
autocomplete.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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