【发布时间】:2020-11-12 22:20:53
【问题描述】:
例如,我有一堆数字数组:
let a = [1,2,3];
let b = [4,5,7];
let c = [11,13,17]
我想创建一个函数,告诉我数组中的数字组合乘以不同数组中的数字会得到某个数字。以下是我到目前为止的代码:
// to get which combination of numbers result to 165
a.forEach(x=>{
b.forEach(y=>{
c.forEach(z=>{
if(x*y*z==165){
console.log(x,y,z)
}
})
})
})
我想创建一个函数,它可以输入一组数字数组,例如:[[1,2],[2,5,],[7,11],[13,17]],并返回数字组合,当它们相乘时,可以得到某个数字。
【问题讨论】:
标签: javascript arrays recursion math multiplication