educative.io

Educative

Set difference implementation test case failing

May I know what’s wrong in below code since one of the test case is failing

Set.prototype.difference = function(secondset) {
  //TODO IMPLEMENT THIS
   var _diff = new Set();
   for(let key in this.set){
    if(!secondset.set.hasOwnProperty(key)){
       _diff.add(key);
     }
   }
  return _diff;
}