say that:
var stringToTest = "Hello i am walking"
And
var searchText = "Hello walking"
I have the following javascript function for filtering
.
var searchSplit = searchText.split(" ");
var num_split = searchSplit.length;
var correctTested = 0;
searchSplit.forEach(function (testString) {
if (stringToTest.indexOf(testString) >= 0) {
correctTested++;
}
});
//Decides if the value are close enough
if (correctTested > 0) {
var percentageCorrect = correctTested / num_split * 100;
return percentageCorrect >= 50;
}
else {
return false;
}
I have never done anything like this and i would like if you would rate or even come with suggestions on how to improve the above code.