Category: Functional Prgramming
Gauging candidates knowledge of Javascript, HTML, CSS skills in less than an hour is certainly a challenging task. It is almost impossible to calibrate candidates success at the company by asking technical questions. If...
Implement the Function.prototype.bind function in javascript bind allows you to change the scope of this also allows you to create functions when called are prefixed with arguments as shown in the solution (aka currying,...
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...
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...
[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....
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...
Reducing an array to a single value Often we have to iterate over the array by accessing multiple items at a time. For example, if you have to find the largest element in an...
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...
Problem Filter only those videos with a rating of 5.0 and return the id of such videos. Solution Further Reading Functional Programming