There is an array section = [[0, 4, 8, 12], [1, 5, 9, 13], [2, 6, 10, 14], [3, 7, 11, 15]]; And the array numbers = [2,3,5,8,10,14,15];
How to determine which numbers of numbers are in the section subarray in an amount of more than 1 pc.? For example, the numbers 10, 14 are in the subarray section[2] , i.e. [2, 6, 10, 14 ].
I tried this:
let result = []; for (let a = 0; a < section.length; a++) { let arr = []; for (let i = 0; i <= numbers.length; i++) { if (section[a].includes(numbers[i])) { arr.push(numbers[i]) } } if(arr.length>1) { result.push(arr); } console.log(result) } Did not work. How can I do that?
array = [[первое число, второе для первого подмассива], [первое, второе для второго подмассива section],[10, 14]]- user7103883первое число, второе для первого подмассиваand theпервое, второе для второго подмассива section? and why did subarrays become 3? - Alexey Shimanskysectionarray. If these numbers are in one sub-array (as here[2, 6, 10, 14]), then add 10, 14 to the result-array. At the output -result = [[10,14]];- user7103883