I am trying to change object key name by comparing two objects values. if the value of second object matches the first object I want to get the key name of the second object and change the first object key name to be the same.
Here is the code I have but it fails to replace the key name of parsedCodedParms
to mappingParms
for (var [key, value] of Object.entries(parsedCodedParams)) {
for (var [k, v] of Object.entries(this.mappingParams)) {
if (v.toLowerCase() == key) {
parsedCodedParams[key] = this.mappingParams[k];
console.log(parsedCodedParams[key])
}
}
}
Example:
parsedCodedParams = {a: "1",b:"2", c: "3"}
mappingParams={ d:"1",z:"5"}
should result
parsedCodedParams= {d: "1",b:"2", c: "3"}