I have a JSON array, and I am trying to apply the toLowerCase method to
the element "first". How would I apply this to the list of customer objects, instead of just one Customer?
Single customer works fine:
console.log(String.prototype.toLowerCase.apply(data.Customers.Customer[0]["first"]))
console.log(String.prototype.toLowerCase.apply(data.Customers.Customer[1]["first"]))
returns jim and jim as expected
But when I try to apply to the array of customers (removed [0]):
console.log(String.prototype.toLowerCase.apply(data.Customers.Customer["first"]))
Error:
TypeError: String.prototype.toLowerCase called on null or undefined at toLowerCase ()
My input json:
var data=JSON.parse('{"Customers":{"Customer":[{"first":["JIM"],"last":["BEAM"],"address":["22. JIM. RD."],"age":["24"],"age2":["2.0"],"Phone":["206-555-0144"]},{"first":["c2"],"last":["r2"],"address":["23. R. RD."],"age":["22"],"age2":["2.2"],"Phone":["999-555-0144"]}]}}')