Finding number selection possibilities

I have the following example data in javascript: var variations = [ {group: 1, id: 1}, {group: 1, id: 2}, {group: 1, id: 3}, {group: 1, id: 4}, {group: 2, id: 5}, {group: 2, id: 6}, {group: 2, id: 7}, {group: 3, id: 8}, {group: 3, id: 9} ]; Let us say I already define the selection using the following variables: var selected_variation_groups = [1,2,3]; var selected_variation_group_ids = [1,2,3,4,5,6,7,8,9]; When I try to find the selection number possibilities from above data, then I would have 24 posibilities: => 1, 5, 8 => 1, 5, 9 => 1, 6, 8 => 1, 6, 9 => 1, 7, 8 => 1, 7, 9 => 2, 5, 8 => 2, 5, 9 => 2, 6, 8 => 2, 6, 9 => 2, 7, 8 => 2, 7, 9 => 3, 5, 8 => 3, 5, 9 => 3, 6, 8 => 3, 6, 9 => 3, 7, 8 => 3, 7, 9 => 4, 5, 8 => 4, 5, 9 => 4, 6, 8 => 4, 6, 9 => 4, 7, 8 => 4, 7, 9 Is there anyone who can help me to give the algorithm for this, or is there anyone who can help me provide javascript code to create those possibilities? The `group`s and `id`s can be unlimited.

以上就是Finding number selection possibilities的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏