JavaScript tutorial: How to create a list using a matrix
P粉617237727
2023-09-06 09:54:44
<p><strong>我有一个像这样的数组</strong></p>
<pre class="brush:php;toolbar:false;">const input_array= [
["black", "blue"],
["large", "medium"],
["a", "b", "c"]
//... is it dynamic can be added many rows
];</pre>
<p><strong>我该如何得到一个像这样的数组:</strong></p>
<pre class="brush:php;toolbar:false;">const finallist = [
["black", "large", "a"],
["black", "large", "b"],
["black", "large", "c"],
["black", "medium", "a"],
["black", "medium", "b"],
["black", "medium", "c"],
["blue", "large", "a"],
["blue", "large", "b"],
["blue", "large", "c"],
["blue", "medium", "a"],
["blue", "medium", "b"],
["blue", "medium", "c"],
]</pre>
<p><strong>请记住input_array是动态的</strong></p>
<p><strong>请告诉我如何做到这一点</strong></p>
You can do this like this:
Have a look at this, it may be helpful: