LoginSignup
3
3

More than 5 years have passed since last update.

JavaScriptで配列の全通りの組み合わせを作る

Last updated at Posted at 2016-11-08

メモの投稿ですみません。。。

const a1 = new Array(10).fill(null).map((a, i) => i) // [0, 1, 2, ..., 9]
const a2 = new Array(10).fill(null).map((a, i) => i) // [0, 1, 2, ..., 9]

a1.reduce((acc,curr) =>{
    acc.push(...a2.map(a => [curr, a]))
    return acc
}, [])
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3