Loop over an array with the given timeout for each element
Problem You are given an array of objects each with its name and timeout value. Iterate over each element inside an array in the interval of the given timeout. Solution We have to set...
Problem You are given an array of objects each with its name and timeout value. Iterate over each element inside an array in the interval of the given timeout. Solution We have to set...
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,...
Fix the following function. When you click on a node, an alert box is supposed to display the ordinal of the node. But it always displays the number of nodes + 1 instead. [codepen_embed...
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” background_layout=”light” text_orientation=”left” text_text_color=”#000000″ use_border_color=”off” border_color=”#ffffff” border_style=”solid”] Currying is a useful technique, with which you can partially evaluate functions. One of the most basic example of the currying is...
[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....
Problem Write a function Array.prototype.map() which can accept one additional argument. function mul(x) { return x * x; } console.log([1, 2, 3].map(mul)); // [1, 4, 9] Modify the function so that it can accept...