-6

How can I build a loop in JavaScript?

var input = {0:['S','M','L','XL'],1:['Red','Blue','Black']};
var output =
{ 
 0:['S','Red'],
 1:['S','Blue'],    
 2:['S','Black'],
 3:['M','Red'],
 4:['M','Blue'],
 5:['M','Black'],
 6:['L','Red'],
 7:['L','Blue'],
 8:['L','Black'],
 9:['XL','Red'],
 10:['XL','Blue'],
 11:['XL','Black'],   
};

I will render Html from output

  • 1
    What have you got? Do you know javascript? – Bálint Sep 17 '16 at 15:37
  • 1
    That isn't valid JavaScript, so we can't help you loop through it. – T.J. Crowder Sep 17 '16 at 15:38
  • 2
    Every basic question about looping through things in JavaScript, whether [arrays](http://stackoverflow.com/questions/9329446/for-each-over-an-array-in-javascript/9329476#9329476) or [objects](http://stackoverflow.com/questions/684672/how-do-i-loop-through-or-enumerate-a-javascript-object), **has been asked and answered already** on SO. Search before posting. – T.J. Crowder Sep 17 '16 at 15:39

1 Answers1

0

I just write this function for him. Please don't justify people from how he write the code. Maybe it's easy to say "Hey! Do you know javascript?".

It's better if you leave some answer or stay quite. His code is valid javascript.

https://gist.github.com/ethaizone/b7d3a833dcdeb80234dde516649ac06d#file-buildmultidimentionarray2-js

EThaiZone
  • 311
  • 1
  • 8