6 kyu

Once

6,034 of 6,172osuushi

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 Trained10889
Total Skips1681
Total Code Submissions68746
Total Times Completed6172
JavaScript Completions6034
CoffeeScript Completions157
Total Stars177
% of votes with a positive feedback rating87% of 316
Total "Very Satisfied" Votes251
Total "Somewhat Satisfied" Votes46
Total "Not Satisfied" Votes19
Ad
Contributors
  • osuushi Avatar
  • jhoffner Avatar
  • siebenschlaefer Avatar
  • hobovsky Avatar
Ad