Category: Functional Prgramming


Currying in javascript

Problem Implement the compound function which returns a function and satisfies the following condition function add10 (a) { return a + 10 } console.log(add10(10)) // 20 console.log(compound(add10)(10)) // 30 Understanding closures, currying, partially applied...

Netflix 0

Closures, currying, partially applied function interview question in javascript

Write a function say which logs the following. console.log( say(‘Foo’)(‘bar’)() ) // => “Foo bar ” console.log( say(‘Hi’)(‘my’)(‘name’)(‘is’)(‘Foo’)() ) // “Hi my name is Foo ” Understanding closures, currying, partially applied functions in javascript...

Netflix 0

flatten three level deep tree

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” saved_tabs=”all” background_layout=”light” text_orientation=”left” text_text_color=”#000000″ use_border_color=”off” border_color=”#ffffff” border_style=”solid” global_module=”1167″] In the previous examples, we saw how to filter two level deep trees with map, filter and concatAll. Let’s try three....

Netflix 0

Implement zip in javascript

Reducing an array to a single value When we need to combine two arrays by progressively taking an item from each and combining the pair. If you visualize a zipper, where each side is...

Netflix 0

Implement concatAll in javascript

Querying Nested Arrays To work with tree data structure we need to flatten them. We will be solving a problem using Array.prototype.forEach(). We will define Array.prototype.concatAll() using Array.prototype.forEach(). We will solve the same problem...

Show Buttons
Hide Buttons