Help for - Algorithms: Find the Symmetric Difference

Help for - Algorithms: Find the Symmetric Difference
0

For this exercise, my solution isn’t able to pass the FCC test. I manually checked it against the tests and the correct values do return… not sure where I’m going wrong, much appreciated for some help thanks!

here’s my solution:

let sym = (...args)=>{
  return(
    args.reduce((prev, curr)=>{
      let prevSet = new Set(prev)
      let currSet = new Set(curr)
      let combArr=[...prevSet, ...currSet]
      
      let setObj = {}
      for(let i=0;i<combArr.length;i++){
        if(setObj[combArr[i]]>=1){
          setObj[combArr[i]]++
        } else {
          setObj[combArr[i]]=1
        }
      }

      let x = []
      for (let key in setObj){
        if(setObj[key]==1){
          x.push(key)
        }
      }
      return x
  }))
}

Hint: Remember that property names (keys) are strings.

yes that was my problem, thanks for your reply