Skip to content

Latest commit

 

History

History
8 lines (8 loc) · 483 Bytes

103-once.md

File metadata and controls

8 lines (8 loc) · 483 Bytes

Problem:

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
### Solution