-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: blog lesson 7 solution * chore: add solution to boilerplates * add hints suggested in #187 * chore: remove unused impport * Improve instructions and error messages * override error when value accessed prematurely * improve exercise instructions for blog #7 * chore: reword the instructions * update wording of override instructions * chore: add syntax errors
- Loading branch information
1 parent
26b293e
commit 2f640bf
Showing
5 changed files
with
61 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
Fill in the body of the `traversePosts()` function. It takes the CID object of the most recent blog post as input. Use that to get the object from IPFS and follow the `prev` links. The return value of the function should be an array with the CID objects of all nodes (including the input CID). | ||
Fill in the body of the `traversePosts()` function. It takes the CID object of the most recent blog post as input. Use that to get the object from IPFS and follow the `prev` links. The return value of the function should be an array with the CID objects of all nodes (including the input CID), starting with the most recent post and ending with the oldest post. | ||
|
||
**Hint**: How do you know when you're out of links? Try using a [`while` loop](https://www.digitalocean.com/community/tutorials/using-while-and-do-while-loops-in-javascript) and checking for the presence of a `prev` field in the current object. If it exists, you're not done yet, and you'll need to reset a variable and run the loop again. You'll need to use the [array `push` method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) to add the relevant CIDs to your array as you go. As noted above, be careful to minimize the number of async calls that could create lag time, and remember that `value` doesn't exist until after your `ipfs.dag.get()` function has returned a result. (See the last example above.) | ||
|
||
Please __do not__ edit the `run` function, only the `traversePosts` function. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters