Skip to main content
Trim chat
Source Link
halfer
  • 20.2k
  • 20
  • 110
  • 207

Logic to create Arrayarray of Array Javascriptarray in JavaScript

I have a little problem with this logic. I need to create a dynamic Array of Array. But But the last object in every Array is not correct. I try some way but still not found expected result. Here

Here the snippet code :

[ [{ "article": "Burger", "order - nr": 1 }, { "article": "Soup", "order - nr": 1 }, { "article": "Noodle", "order - nr": 1 }], [{ "article": "Steak", "order - nr": 2 }, { "article": "Chicken Wings", "order - nr": 2 }], [{ "article": "Coffee", "order - nr": 3 }], [{ "article": "Rice", "order - nr": 4 }] ] 

]

My expected result there is 4 Array base on order-nr key. So the total sub Array will depend on order-nr key. Any suggestion will help for me. Thanks in Advance

Logic create Array of Array Javascript

I have a little problem with this logic. I need to create a dynamic Array of Array. But the last object in every Array is not correct. I try some way but still not found expected result. Here the snippet code :

[ [{ "article": "Burger", "order - nr": 1 }, { "article": "Soup", "order - nr": 1 }, { "article": "Noodle", "order - nr": 1 }], [{ "article": "Steak", "order - nr": 2 }, { "article": "Chicken Wings", "order - nr": 2 }], [{ "article": "Coffee", "order - nr": 3 }], [{ "article": "Rice", "order - nr": 4 }] 

]

My expected result there is 4 Array base on order-nr key. So the total sub Array will depend on order-nr key. Any suggestion will help for me. Thanks in Advance

Logic to create array of array in JavaScript

I have a little problem with this logic. I need to create a dynamic Array of Array. But the last object in every Array is not correct. I try some way but still not found expected result.

Here the snippet code :

[ [{ "article": "Burger", "order - nr": 1 }, { "article": "Soup", "order - nr": 1 }, { "article": "Noodle", "order - nr": 1 }], [{ "article": "Steak", "order - nr": 2 }, { "article": "Chicken Wings", "order - nr": 2 }], [{ "article": "Coffee", "order - nr": 3 }], [{ "article": "Rice", "order - nr": 4 }] ] 

My expected result there is 4 Array base on order-nr key. So the total sub Array will depend on order-nr key.

edited tags
Link
Nick Parsons
  • 51.7k
  • 6
  • 61
  • 80
added 31 characters in body
Source Link
MrX
  • 991
  • 3
  • 18
  • 45
  [   [{ article"article": "Burger", order"order - nrnr": 1   }, { article"article": "Soup", order"order - nrnr": 1   }, { article"article": "Noodle", order"order - nrnr": 1   }, { article"article": "Steak", order"order - nrnr": 2   }],   [{ article"article": "Chicken Wings", order"order - nrnr": 2   }, { article"article": "Coffee", order"order - nrnr": 3   }],   [{ article"article": "Rice", order"order - nrnr": 4   }]  ] 
  [   [{ article: "Burger", order - nr: 1   }, { article: "Soup", order - nr: 1   }, { article: "Noodle", order - nr: 1   }, { article: "Steak", order - nr: 2   }],   [{ article: "Chicken Wings", order - nr: 2   }, { article: "Coffee", order - nr: 3   }],   [{ article: "Rice", order - nr: 4   }] ] 
 [ [{ "article": "Burger", "order - nr": 1 }, { "article": "Soup", "order - nr": 1 }, { "article": "Noodle", "order - nr": 1 }, { "article": "Steak", "order - nr": 2 }], [{ "article": "Chicken Wings", "order - nr": 2 }, { "article": "Coffee", "order - nr": 3 }], [{ "article": "Rice", "order - nr": 4 }]  ] 
Add exected result
Source Link
MrX
  • 991
  • 3
  • 18
  • 45
Loading
Add code fences and stack snippets
Source Link
deepakchethan
  • 5.6k
  • 1
  • 26
  • 34
Loading
Source Link
MrX
  • 991
  • 3
  • 18
  • 45
Loading