Hello, I completed a challenge in the intermediate scripting section, with using code from stackoverflow. I learned a new way how to use filter, and the method includes(). Is copying code a good practice in general for beginner, as i learned a new method when copying the code?
my code:
function diffArray(arr1, arr2) {
let result = arr1.filter(word => !arr2.includes(word))
let result2 = arr2.filter(word => !arr1.includes(word)).concat(result)
return result2
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])
from stackoverflow
var fullWordList = ['1','2','3','4','5'];
var wordsToRemove = ['1','2','3'];
var filteredKeywords = fullWordList.filter((word) => !wordsToRemove.includes(word));
console.log(filteredKeywords);