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

93
Views
Jacascript Loop - Skip A Step based on a variable

I have a For loop with steps where I need to be able to skip a step if a value in a variable equals a certain text.

For example - in the below code I would like to skip step 0 if that var airport does not equal JFK:

var airport = 'JFK';

for (let step = 0; step < 2; step++) {
    rec.setCurrentSublistValue({
        sublistId: 'item',
        fieldId: 'item',
        value: 1261,
        forceSyncSourcing: true
    })
)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You want to use a conditional statement with continue to terminate that particular iteration if the condition is met.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/continue

Simple working snippet below. Note loop 0 is missed.

var airport = 'JFK';

for (let step = 0; step < 4; step++) {
   if (airport == 'JFK' && step==0) {continue}
    // code;
    // code;
    
    console.log(`step ${step} executed`);
}

console.log("loop finished");

about 4 years ago · Juan Pablo Isaza Report
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!