Tell us what’s happening:
cannot implement remove function
Your code so far
function Set() {
// the var collection will hold our set
var collection = [];
// this method will check for the presence of an element and return true or false
this.has = function(element) {
return collection.indexOf(element) !== -1;
};
// this method will return all the values in the set
this.values = function() {
return collection;
};
this.add = function(el) {
return this.has(el) ? false : Boolean(collection.push(el));
};
this.remove = function(el){
if (this.has(el)) {
collection.splice(collection.indexOf(ele),1)
return true
}
else{
return false;
}
};
this.size = function(){
return collection.length;
};
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
.
Challenge: Create a Set Class
Link to the challenge: