Tell us what’s happening:
is it a bug or a feature or am i the only one having this problem.
if i use arrow function in filter with curly bracket they dont work
but if i remove the curly bracket they work just fine
Intermediate Algorithm Scripting: Seek and Destroy(Works)
function destroyer(arr) {
var arg = […arguments].slice(1)
return arr.filter(x=>
!arg.includes(x)
)
}
Intermediate Algorithm Scripting: Seek and Destroy(Don’t)
function destroyer(arr) {
var arg = […arguments].slice(1)
return arr.filter(x=>{
!arg.includes(x)
})
}
Intermediate Algorithm Scripting: Diff Two Arrays(Works)
function diffArray(arr1, arr2) {
var newArr =
return arr1.concat(arr2).filter(x =>!arr1.includes(x) || !arr2.includes(x))
}
Intermediate Algorithm Scripting: Diff Two Arrays(Works)
function diffArray(arr1, arr2) {
var newArr =
return arr1.concat(arr2).filter(x =>{!arr1.includes(x) || !arr2.includes(x)})
}
Intermediate Algorithm Scripting: Diff Two Arrays(Using Map Works Fine)
function diffArray(arr1, arr2) {
var newArr = ;
arr1.map(x=>{
if(!arr2.includes(x)){
newArr.push(x)}
})
arr2.map(x=>{
if(!arr1.includes(x)){
newArr.push(x)}
})
return newArr;
}
**Link to the challenge:1**
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy
**Link to the challenge:2**
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays