I have json with several values. I can access the last value with json[json.length -1].ADESC.
Problem is, that the last value, or several last values can be '...'. I need to get the last value other than this '...'.
here is an example of the data:
start
...
working
...
...
...
In this case, I need to get the 'working'. There can be any rows with '...' or there can be many last rows with '...'.
I tried this:
if( json[json.length -1].ADESC != '...' ) {
json[json.length -1].ADESC
} else if ( json[json.length -2].ADESC != '...' ) {
json[json.length -2].ADESC
} else if ( json[json.length -3].ADESC != '...' ) {
json[json.length -3].ADESC
} else if
...
but it is not the best way how to accomplish this task I think and I'm afraid the better solution is out of my skills. Thank you.
I tried to add for loop. There is no error when it's executed, but unfortunately no data at all :) I have a little problem to create this reverse loop :(
for(var i=-1; i<(-(json[json.length])); i--){
if(json[json.length -i].ADESC != '. . .') {
json[json.length -i].ADESC; } }