diff --git a/snippets/walkThrough.md b/snippets/walkThrough.md index a2ac53975..989f46e4f 100644 --- a/snippets/walkThrough.md +++ b/snippets/walkThrough.md @@ -2,7 +2,7 @@ title: walkThrough tags: object,recursion,generator,advanced firstSeen: 2020-12-31T13:03:15+02:00 -lastUpdated: 2020-12-31T13:03:15+02:00 +lastUpdated: 2021-11-15T13:18:18+02:00 --- Creates a generator, that walks through all the keys of a given object. @@ -11,7 +11,7 @@ Creates a generator, that walks through all the keys of a given object. - Define a generator function, `walk`, that takes an object and an array of keys. - Use a `for...of` loop and `Object.keys()` to iterate over the keys of the object. - Use `typeof` to check if each value in the given object is itself an object. -- If so, use the `yield*` expression to recursively delegate to the same generator function, `walk`, appending the current `key` to the array of keys. Otherwise, `yield` the an array of keys representing the current path and the value of the given `key`. +- If so, use the `yield*` expression to recursively delegate to the same generator function, `walk`, appending the current `key` to the array of keys. Otherwise, `yield` an array of keys representing the current path and the value of the given `key`. - Use the `yield*` expression to delegate to the `walk` generator function. ```js