I
I
it_pear_yurec2021-06-12 20:35:38
JavaScript
it_pear_yurec, 2021-06-12 20:35:38

How to implement such a cycle?

Wrote a for loop by iteration from an array, tobish 7 elements of the array, the loop fulfills 7 times and a mustache. But here I had to write a loop within a loop so that the first loop also runs 7 times, but does not wait until the loop runs inside it in order to proceed to the execution of its next iteration, how to do this?

const ads= [
      '1',
      '2',
      '3',
      '4',
      '5',
      '6',
      '7'
    ];
const ports = [
      '9052',
      '9053',
      '9054',
      '9055',
      '9056',
      '9057',
      '9058'
    ];
for (const link of ads) {
    console.log(link);
        for (const port of ports) {
          console.log(link);
          await scrape( link.href);
        }
      }

comes out like this:
1
9052, 9053, 9054, 9055, 9056, 9057, 9058 2
9052
, 9053, 9054, 9055, 9056, 9057 , 9058 . but IT IS NECESSARY LIKE THIS: 1 9052 2 9053 3 9054 I HOPE you understand))))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question