I am working with the following function to search for a term entered in a search engine.
I search for a value within an array, at a specific position in the array to check if it exists.
/***** BUSCAR EN EL ARRAY PRODUCTOS POR VALOR Y POSICION ****/
function buscar(mi_array, valor, pos){
count = 0;
var results = mi_array.filter(function (mi_array) { return (mi_array[pos].toUpperCase().startsWith(valor.toUpperCase())) && count++ < 36; });
var firstObj = (results.length > 0) ? results[0] : null;
return results;
}
My problem comes when the user looks for a product with a tilde and in the array where he looks for the function it is without a tilde and vice versa.
How could I deal with this problem?
Try replacing the startWith(...) in the return with the following:
It should work as it converts all accented vowels or ü's to their respective vowels.