I have to creater function ( lets call it filterItems), that will filter 2 arrays ( take all the numbers above 0) and the result should return new array with all the number above 0 from 2 arrays.
f.e input
[1, -2, 3] [1, 0]
output
[1, 3, 1]
I tried by using map, but it failed.
function filterItems(arr,array) {
return arr.map(number => arr > 0 , array > 0)
}
Thank eveyrone for their time and i will be grateful for any tips.
const result = [...array1, ...array2].filter(item => item > 0)?function filterItems(arr, array) { return [...arr, ...array].filter(item => item > 0) }. It is exactly the same concept, but you use the resulting array as a the returned value for a function instead of assigning it to a variable.