Just to be sure everyone is on the same page for the pipe function, I rewrote it using the function keyword and a for...of loop (and human-readable variable names).
This is just an imperative way of writing what Andrea wrote with the reduce method. Same thing, different way of writing it. Maybe a little more understandable for newcomers with the imperative way. I hope that helped!
Seems kind of ironic that someone would need to write code in an imperative way to make it more readable in an article that claims declarative programming is easier to read. 😂🤣
You are correct! I think that when beginners start to see things like map or reduce or findIndex they get lost quicker than when using this way of writing (which uses concepts that are present in other imperative languages). Maybe a little more approachable to begin the smooth transition to the Array methods.
Hi there, great article!
Just to be sure everyone is on the same page for the
pipe
function, I rewrote it using thefunction
keyword and afor...of
loop (and human-readable variable names).This is just an imperative way of writing what Andrea wrote with the
reduce
method. Same thing, different way of writing it. Maybe a little more understandable for newcomers with the imperative way. I hope that helped!Thank you.
Seems kind of ironic that someone would need to write code in an imperative way to make it more readable in an article that claims declarative programming is easier to read. 😂🤣
You are correct! I think that when beginners start to see things like
map
orreduce
orfindIndex
they get lost quicker than when using this way of writing (which uses concepts that are present in other imperative languages). Maybe a little more approachable to begin the smooth transition to the Array methods.Thanks Amin for the "human-readable" version of pipe! 😁
The article supposes some degree of familiarity with JS. Maybe I need to mention some prerequisites in the intro part.
You are very welcome friend. I also understand that this topic could last for hours of reading but I think we can agree that we agree. 😂
Anyway great article again I really enjoy reading this through. Keep up the good work!