fix(learn): update the return Object.values & solution (#40451)
This commit is contained in:
@ -25,7 +25,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The union of `["a", "b", "c"]` and `["c", "d"]` should return `["a", "b", "c", "d"]`.
|
||||
The union of a Set containing values ["a", "b", "c"] and a Set containing values ["c", "d"] should return a new Set containing values ["a", "b", "c", "d"].
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -67,12 +67,12 @@ class Set {
|
||||
}
|
||||
// This method will return all the values in the set
|
||||
values() {
|
||||
return Object.keys(this.dictionary);
|
||||
return Object.values(this.dictionary);
|
||||
}
|
||||
// This method will add an element to the set
|
||||
add(element) {
|
||||
if (!this.has(element)) {
|
||||
this.dictionary[element] = true;
|
||||
this.dictionary[element] = element;
|
||||
this.length++;
|
||||
return true;
|
||||
}
|
||||
@ -113,12 +113,12 @@ class Set {
|
||||
}
|
||||
|
||||
values() {
|
||||
return Object.keys(this.dictionary);
|
||||
return Object.values(this.dictionary);
|
||||
}
|
||||
|
||||
add(element) {
|
||||
if (!this.has(element)) {
|
||||
this.dictionary[element] = true;
|
||||
this.dictionary[element] = element;
|
||||
this.length++;
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user