6 kyu

Once

6,049 of 6,187osuushi

Description:

You'll implement once, a function that takes another function as an argument, and returns a new version of that function that can only be called once.

Subsequent calls to the resulting function should have no effect (and should return undefined).

For example:

logOnce = once(console.log)
logOnce("foo") // -> "foo"
logOnce("bar") // -> no effect
Functional Programming
Fundamentals

More By Author:

Check out these other kata created by osuushi

Stats:

CreatedFeb 22, 2014
PublishedFeb 22, 2014
Warriors Trained10911
Total Skips1682
Total Code Submissions68780
Total Times Completed6187
JavaScript Completions6049
CoffeeScript Completions157
Total Stars177
% of votes with a positive feedback rating87% of 317
Total "Very Satisfied" Votes251
Total "Somewhat Satisfied" Votes47
Total "Not Satisfied" Votes19
Ad
Contributors
  • osuushi Avatar
  • jhoffner Avatar
  • siebenschlaefer Avatar
  • hobovsky Avatar
Ad