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
|
```js
|
||||||
assert(
|
assert(
|
||||||
@ -67,12 +67,12 @@ 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);
|
||||||
}
|
}
|
||||||
// This method will add an element to the set
|
// This method will add an element to the set
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -113,12 +113,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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user