-
create object and object's combination
over 9 years ago
-
over 9 years ago
This is the solution to the above problem....
<html> <head> <script> var color = ["red", "yellow", "blue"]; var size = ["xl", "xxl", "xxxl"]; var style = ["cotton", "silk", "jins"]; var i=0; var j=0; var k=0; var counter = 0; while (i<color.length) { console.log("*****"+color[i]+"********"); while(j<size.length) { while(k<style.length) { console.log("lbl- "+counter+"= "+" "+color[i]+" "+size[j]+" "+style[k]+" "); k++; counter++; } k=0; j++; } k=0; j=0; i++; } </script> </head> </html>
Thanks For any queries leave the comment..
-
-
over 9 years ago
Try this jQuery function..
<script type="text/javascript"> var color = ["red", "yellow", "blue"]; var size = ["xl", "xxl", "xxxl"]; var style = ["cotton", "silk", "jins"]; function GetVal() { var arr = new Array(); $.each(color, function (i, colorVal) { $.each(size, function (j, sizeVal) { $.each(style, function (k, styleVal) { arr.push(colorVal + " - " + sizeVal + " - " + styleVal); }); }); }); return arr; } </script>
This will return an array of string as per your requirement.
-
2 Answer(s)