The code that runs the ProtoSchool website. Visit https://proto.school for interactive tutorials on decentralized web protocols. Explore IPFS and Filecoin through code challenges, code-free lessons, and local events.
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)]
}
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: