function *draw(first = 1, two = 2, three = 3) { let one_arr = ['a1', 'a2', 'a3', 'a4'] let two_arr = ['b1', 'b2', 'b3', 'b4'] let three_arr = ['c1', 'c2', 'c3', 'c4'] let judge = [] for (let i = 0; i< first; i++) { let random = Math.floor(Math.random() * one_arr.length) judge = judge.concat(one_arr.splice(random, 1)) } for (let i = 0; i< two; i++) { let random = Math.floor(Math.random() * two_arr.length) judge = judge.concat(two_arr.splice(random, 1)) } for (let i = 0; i< three; i++) { let random = Math.floor(Math.random() * three.lenght) judge = judge.concat(three_arr.splice(random, 1)) } for (let i of judge) { yield console.log(i) } } let d = draw() d.next()
版权属于:
emer
文章声明:
本文版权内容属于《快乐小窝》转载请标明出处
评论一下?