Tell us what’s happening:
Describe your issue in detail here.
My question pertains to the structure choice for ‘dictionary’ in the constructor & the example code (i.e. ’ const set1 = new Set([1, 2, 3, 5, 5, 2, 0]); )
Beau used an array at that site & that makes sense but on FCC an object is being used to store an array. My question and confusion is this:
If an object is key:value pairs then what is the example code ‘set1’? Is it a neither an array or object but a prototype? (i.e. ‘// output: {1, 2, 3, 5, 0}’<-?)
**Your code so far**
class Set {
constructor() {
// Dictionary will hold the items of our set
this.dictionary = {};
this.length = 0;
}
// This method will check for the presence of an element and return true or false
has(element) {
return this.dictionary[element] !== undefined;
}
// This method will return all the values in the set
values() {
return Object.values(this.dictionary);
}
// Only change code below this line
add(element) {
let firstSet = values();
if(firstSet.indexOf(element) === -1){
dictionary.push(element);
return true;
}
return false;
}
remove(element) {
let firstSet = values();
const index = values().indexOf(element);
if(index !== -1){
values().splice(index, 1)
return true;
}
return false;
}
// Only change code above this line
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36
Challenge: Create a Set Class
Link to the challenge: