Hello i'm a beginner in nodejs and i just wanted to know how can i compare 2 array and store the difference into an other array.
i've done this to start :
const array1 = [1,2,3,4,5,6,7,8,9,0];
const array2 = [5,2,8,9];
const array3 = []; //wanted [1,3,4,6,7,0]
var i=0
array2.forEach(function(element){
const found = array1.find(element => element !== array2[i])
array3.push(found)
i++
})
console.log(array3)
Thanks a lot !