I try to set "*****" to employee_salary property
this is my js code
var data = context.getVariable("data");
var jsonObject = JSON.parse(data);
for(var i = 1; i <= jsonObject.length; i++) {
print(jsonObject[i]) //[object Object]
print(jsonObject[i].employee_salary)
jsonObject[i].employee_salary = "*****"; //undefined
}
this is my data from extracted variable
but I get response error \"TypeError: Cannot set property \"employee_salary\" of undefined to \"*******\".
this is log from print()
What is the problem?
How can I resolve it?
Thank you.
You're looping through an array.. however your for loop starts from i = 1, and goes until i <= array length.. This means you're starting from the second element, and then going beyond the bounds of your array
Thank you
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |