0
Hours
0
Minutes
0
Seconds
You need Login/Signup to run/submit the code.

Implement a function that accepts a callback and restricts its invocation to at most once | Lodash Polyfills | Frontend Problem Solving

@Devtools Tech
374

In this question, you need to create a function that accepts a callback and restricts its invocation to at most once.

Repeat calls to the function return the value of the first invocation. The callback is invoked with the this binding and arguments of the created function.

Syntax

once(callback);

Arguments

  • callback (Function): The function to restrict.

Returns

  • (Function): Returns the new restricted function.

Submission

Start the timer, complete your solution, test your solution against the test cases provided by the platform, and submit it. Ideally, you should finish this question within 30 mins.

Share your solution with us on twitter or linkedin.

Loading IDE...