Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Javascript, removing a row within an object

Best way to remove a row off an object based off a certain condition?

Down below I made a function to remove any row where the difference of the amount within latest row and any other row is greater than 300.

bank_data = [{"arrival_time":"12:00","amount":"900","id":"BS"},  
{"arrival_time" :"12:00","amount":"300","id":"BD"},
{"arrival_time" :"01:00","amount":"400","id":"SW"},
{"arrival_time" :"03:00","amount":"800","id":"OS"},
{"arrival_time" :"03:00","amount":"500","id":"SF"},
{"arrival_time" :"04:00","amount":"600","id":"SJ"},
{"arrival_time" :"04:00","amount":"600","id":"FS"},
{"arrival_time" :"06:00","amount":"900","id":"JC"}];

function update_list(obj){
    if(obj.length > 0) {
        latest = obj.length -1; 
        for(var i = 0; i < obj.length; i++){
            if((obj[latest].amount - obj[i].amount) > 300){
                obj.splice(i, 1);//remove the ith row of the object
            }
        }
    }
    return obj;
}


Goal Result

bank_data = [{"arrival_time":"12:00","amount":"900","id":"BA"},  
{"arrival_time" :"03:00","amount":"800","id":"OS"},
{"arrival_time" :"04:00","amount":"600","id":"SJ"},
{"arrival_time" :"04:00","amount":"600","id":"FS"},
{"arrival_time" :"06:00","amount":"900","id":"JC"}];
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!