I'm trying to search a string variable (a city name that comes from an array) in another string (an address string). Here is the sample code :
var cities = [....];
var address ='....';
var cityName ='';
for(var i=0; i < cities.length){
cityName = cities[i];
console.log(cityName);
if(address.search(cityName) > 0){
return cityName;
}
}
But, even though there is not a special character problem in the cityName , search method returns -1 for an existing cityName.
Because, when i copy the cityName from the console and paste it to the js file again, it appears double dot on the i letter (i couldn't write here, it turned to normal i) so the method cannot find the city.
Is it an encoding problem or what?
S.O.S