We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// Challenge 7 const intersection = (arrays) => { return arrays.reduce((acc, curr) => { return curr.filter(el => acc.includes(el)); }); };
// console.log(intersection([5, 10, 15, 20], [15, 88, 1, 5, 7], [1, 10, 15, 5, 20])); Uncaught TypeError: curr.filter is not a function
Should be: const intersection = (...arrays) => { return arrays.reduce((acc, curr) => { return curr.filter(el => acc.includes(el)); }); };
and similar error downside :)
The text was updated successfully, but these errors were encountered:
Yep, same error spotted here. An alternative solution is to rewrite the test statement:
Instead of :
// console.log(intersection([5, 10, 15, 20], [15, 88, 1, 5, 7], [1, 10, 15, 5, 20]));
test with:
// console.log(intersection([[5, 10, 15, 20], [15, 88, 1, 5, 7], [1, 10, 15, 5, 20]]));
Final code would be:
// Challenge 7 function intersection(arrays) { return arrays.reduce((acc, curr) => { return curr.filter(el => acc.includes(el)); }); } // console.log(intersection([[5, 10, 15, 20], [15, 88, 1, 5, 7], [1, 10, 15, 5, 20]]));
Same for challenge 8
Sorry, something went wrong.
Actually, challenge 7 should be:
function intersection(...arrays) { return arrays.reduce((acc, curr) => { return curr.filter(el => acc.includes(el)); }); }
No branches or pull requests
// Challenge 7
const intersection = (arrays) => {
return arrays.reduce((acc, curr) => {
return curr.filter(el => acc.includes(el));
});
};
// console.log(intersection([5, 10, 15, 20], [15, 88, 1, 5, 7], [1, 10, 15, 5, 20]));
Uncaught TypeError: curr.filter is not a function
Should be:
const intersection = (...arrays) => {
return arrays.reduce((acc, curr) => {
return curr.filter(el => acc.includes(el));
});
};
and similar error downside :)
The text was updated successfully, but these errors were encountered: