Update the return value of values method in create a set class challenge (#40450)

* fix #40443

* Fix the solution add method
This commit is contained in:
Kai-Chin Huang
2020-12-16 09:15:33 +08:00
committed by GitHub
parent 7c19c82076
commit a1928ba272

View File

@ -165,7 +165,7 @@ class Set {
// This method will return all the values in the set // This method will return all the values in the set
values() { values() {
return Object.keys(this.dictionary); return Object.values(this.dictionary);
} }
// Only change code below this line // Only change code below this line
@ -188,12 +188,12 @@ class Set {
} }
values() { values() {
return Object.keys(this.dictionary); return Object.values(this.dictionary);
} }
add(element) { add(element) {
if (!this.has(element)) { if (!this.has(element)) {
this.dictionary[element] = true; this.dictionary[element] = element;
this.length++; this.length++;
return true; return true;
} }