Giving this in js:
let data={"vets":[{"id": 1,"lt": "6","ln": 2702,"ls": "2011-07-02T00:00:00"}]};
I want to use the split() function on the ls property.
data['vets'].ls is giving the value: "2011-07-02T00:00:00".
I save it to a variable like this:
let str = data['vets'].ls;
When i run str.split('T')[0] to get only 2011-07-02, i get an error of:
Uncaught TypeError: Cannot read property 'split' of null
Edit: The array i have is about 3000 items. I am using the map() functionn to go on all of them like this:
data['vets'].map(function(vet){
let str = vet['ls'];
let short = str.split('T');
vet['ls'] = short[0];
})
What can be the reason for it? Thanks.
data['vets'][0].lsbecausedata['vets']is an array.data['vets'].lsis not returning"2011-07-02T00:00:00", it's returningundefinedsincevetsis an array.ls"YYYY-MM-DDTHH:MM:SS" to just "YYYY-MM-DD" i.imgur.com/lsvVOp2.png