0

Here is the code i am facing problem

    for (var j = 0; j < 3; j++) {
            console.log("for loop"+j);
               Data.getById(item)
                    .then(function (data) {
                        console.log("then J"+j);
                       },
                    function (error) {
                        alert(JSON.stringify(error));
                    });                            
    }

When i am running the chuck of code its printing in console for loop 1,for loop 2,for loop 3 first then printing then J 3,then J 3,then J 3 three times but i want it should print for loop 1 , then j 1, for loop 2 then j 2,for loop 3 , then j 3 order

Abhijit Chakra
  • 3,201
  • 37
  • 66

0 Answers0