Skip to content

Commit 42e5c0c

Browse files
authored
Update compact-object.ts
1 parent 15b1527 commit 42e5c0c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

TypeScript/compact-object.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ function compactObject(obj: Obj): Obj {
1414
if (typeof obj !== "object") {
1515
return obj;
1616
}
17-
return Object.keys(obj).reduce(
18-
(accu, key) => {
19-
accu[key] = compactObject(obj[key]);
17+
return Object.entries(obj).reduce(
18+
(accu, [key, value]) => {
19+
accu[key] = compactObject(value);
2020
if (!Boolean(accu[key])) {
2121
delete accu[key];
2222
}

0 commit comments

Comments
 (0)