I have a problem. I want to replace in my dataList certian values like ., Ü and so on. I also want to add them to a new object value firstname. How could I add the replaced name to firstname? Is this replace a fast way, or is there any better and faster way?
var dataList = [
{
"Name": "Max",
"Age": "42",
"Subname": "Ünger Pes"
},{
"Name": "Bertha",
"Age": "53",
"Subname": "Kl. Fr"
}];
dataList.map(function(item) {
var keyse = Object.keys(item);
for (var i in keyse) {
item['firstname'[i]] = item[keyse[i]].toLowerCase().replace('.','').replace('
','').replace('ü','ue');
}
});
What I got
[
{
"Name": "Max",
"Age": "42",
"Subname": "Ünger Pes",
"f": "max",
"i": "42",
"r": "uengerpes"
},
{
"Name": "Bertha",
"Age": "53",
"Subname": "Kl. Fr",
"f": "bertha",
"i": "53",
"r": "klfr"
}
]
What I want
[
{
"Name": "Max",
"Age": "42",
"Subname": "Ünger Pes",
"firstname" : "uengerpes"
},{
"Name": "Bertha",
"Age": "53",
"Subname": "Kl. Fr",
"firstname" : "klfr"
}]