I have a JSON object with keys and values, where some of the values are empty strings. I want to replace those empty values with the corresponding key name. However, when trying to get the value of a key within the loop, it returns undefined.
JSON:
"Forget": "",
"Login": "Login2"
JavaScript:
...
var jsonKeys = Object.keys(json),
jsonKeysLength = jsonKeys.length;
for(var i=0; i < jsonKeysLength; i++){
var key,
translateValue = jsonKeys[i][key];
if( translateValue == "" ) {
translateValue = jsonKeys[i];
}
}
return json;
...