Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to fetch last value in the for loop using javascript?

enter image description here

    var new_data = $.parseJSON(data);
        for (var j = 0; j < new_data.all_soa_details.length; j++) {
          var td7_contact = new_data.all_soa_details[j].bal; //100,200,200,50 . here i need to fecth 50 only
          let td77_contact = Math.abs(td7_contact);
        }

i am getting values 100, 200,40,60, 50.. Here i need to fetch 50 becoz its last valuje in the for loop .How to get this last value?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

new_data.all_soa_details[new_data.all_soa_details.length - 1].bal

should give you the expected result

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading