Answer the question
In order to leave comments, you need to log in
Generate numbers from an array?
Take 15 numbers out of 36 numbers that are not in the array.
You need to take a combination of 15 numbers and form an array of them. The maximum number in the array should not exceed 36.
There is an array:
let arr=[
[1,3,4,5,2,6],
[8,9,10,12,11,13]
]
Answer the question
In order to leave comments, you need to log in
We create an intermediate arr2 to store all the values from the main array into it, and then we store in arr3 everything that is less than 37 and is not available in the general array.
let arr=[
[1,3,4,5,2,6],
[8,9,10,12,11,13]
]
let arr2 = [];
let arr3 = [];
for(let i = 0; i < arr.length; i++) {
arr2 = [...arr2, ...arr[i]];
}
for(let k = 0; k < 37; k++) {
if (!arr2.includes(k)) {
arr3.push(k);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question