DEV Community

Discussion on: Monad Say What? (Part 1)

Collapse
 
antonrich profile image
Anton • Edited

Do you think the concept "having the end mind" is applicable here?

and

So, basically you first show this at the start of the article (introduce the end goal):

indexById(null)
//=> {}

indexById([])
//=> {}

indexById([ 1, 2, 3 ])
//=> {}

indexById(data)
//=> {
//   9CYolEKK: { id: '9CYolEKK', learner: 'Molly' },
//   gbdCC8Ui: { id: 'gbdCC8Ui', learner: 'Thomas' },
//   1AceDkK_: { id: '1AceDkK_', learner: 'Lisa' }
// }

And then you just show the imperative approach and then show how to refactor that approach into the functional one and what are the benefits.