ES6 answer to 19 Exercise 3 - Except Element

const numbers = [1, 2, 3, 4];

const output = except(numbers, [1, 2]);

function except(array, excluded) {
return array.filter((num) => !excluded.includes(num));


Worked great for me! :slight_smile:

Exactly. I was going to add the comment myself because that was what I came up with as well especially when Mosh devoted a lesson to the filter method. I thought it should have at least been mentioned. Now as a writer of automated scripts and hobbyist in game programming, I am not a believer in he/she who writes the most elegant chained solution (to quote Mosh: β€œWhat is going on here?”) wins (depending on the users of the code, the performance, and if it works, hell, code with good practices and leave refactoring for another day) but as much as Mosh made comments like ugly code and amateurish at his own initial attempts, the solution up above is much shorter, more β€œelegant”, and self-documenting.