I would like to get rid of special characters in a string by comparing each of it's character to a character in an array and replacing it with a matching one. The function below does not throw any errors but keeps returning the string unchanged
var name = "przykład";
// the characters i'm looking for in a string:
var charList = ["Ą","ą","Ć","ć","Ę","ę","Ł","ł","Ó","ó","Ś","ś","Ź","ź","Ż","ź"];
// the characters i'd like to replace them with:
var replaceList = ["A","a","C","c","E","e","L","l","O","o","S","s","Z","z","Z","z"];
var limit = name.length;
for (i = 0; i < limit; i++){
for(var j in charList){
name.charAt(i) === charList[j] ? name.replace(name.charAt(i), replaceList[j]) : "";
}
}
return name;
I know this question will be most likely closed as "too localized" and it's propably a stupid and easy mistake i've made but still I would really appreciate any help with this