Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson Feedback%3A Blog - Lesson 7 (Traverse through all posts, starting with the most recent) #799

Open
andrewzhurov opened this issue May 13, 2022 · 0 comments
Labels
lesson-feedback Feedback on a specific lesson

Comments

@andrewzhurov
Copy link

andrewzhurov commented May 13, 2022

URL of the lesson that's confusing:
https://proto.school/blog/07

What's confusing about this lesson?
It suggests to use push mutating-op in order to assemble the result,
mutations are evil,
perhaps it can be suggested to use recursion?

Resulting function would be something of this sort:

const traversePosts = async (cid) => {
  // Your code goes here
  postGetResult = await ipfs.dag.get(cid)
  post = postGetResult.value

  return !post.prev ? [cid] : [cid, ... await traversePosts(post.prev)]
}
@andrewzhurov andrewzhurov added the lesson-feedback Feedback on a specific lesson label May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lesson-feedback Feedback on a specific lesson
Projects
None yet
Development

No branches or pull requests

1 participant