0

Ask: I want to convert below code of nested loops to promise, such that I can wait for all the promises to resolve.

Issue: I can't figure out syntax or approach to write a promise for 3 nested loop in one.

Below is the Code, I am trying to convert to promise. Any help on this is really appreciated:

for (var i of LOOP1) {
        
          for (var j of LOOP2) {
          
            if (LOOP1.length === 1 && !i.code) {
              i.code = j.code;
            }
              
              for (var k of i.UpdatedName) {
                k.name = j.name;
              }
              
              for (var test of i.CommonNames) {
                CommonNames.name = j.name;
              }

            }
          }
        }
Programmermid
  • 588
  • 3
  • 9
  • 30
  • Who marked this as duplicate? Do you know difference between stand alone loops and nested loops? Can you make the above code work with suggested answer? I dont think so. Maybe you can discuss with me on how you think thats a duplicate? – Programmermid Mar 02 '22 at 22:08
  • 1
    @CertainPerformance did. And I find your distinguishing argument unconvincing. – pppery Mar 02 '22 at 23:54
  • Why are you trying to convert this to promises? There's nothing asynchonous in this code. If your question is not answered by the linked duplicate question, you could try including a better description of what you're trying to achieve, and a better code example that demonstrates a need for promises. For now I'm voting to keep this question closed. – Andru Mar 03 '22 at 10:28

0 Answers0