For loop inside For Loop Javascript

前端 未结 2 964

For some reason this statement is skipping some data.Am I missing a continue statement somewhere or something ? Here is the code

for (var i = 0, len = data.ORDER         


        
2条回答
  •  无人及你
    2021-02-14 23:07

    you are using "i" in your outer an inner loops. you need to use a different variable in the inner loop: i have used "inner" below as and example.

    for (var i = 0, len=data.ORDER_STATUS[0].ORDERS.length; i < len; i++) {
        if (data.ORDER_STATUS[0].ORDERS[i].SEC_TYPE=="MLEG"){
          for (var inner = 0; inner  < data.ORDER_STATUS[0].ORDERS[i].LEGS.length; inner ++) {
              // do something
          }
        }
      }
    

提交回复
热议问题