Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Once #10

Open
jawayang opened this issue May 31, 2016 · 3 comments
Open

Once #10

jawayang opened this issue May 31, 2016 · 3 comments
Assignees

Comments

@jawayang
Copy link
Contributor

題目:

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:

function foo() {
   console.log('foo');
}

fooOnce = once(foo)
fooOnce() // -> "foo"
fooOnce() // -> no effect

http://www.codewars.com/kata/5307ff5b588fe6d7000000a5/train/javascript

翻譯:
實現一個函數 once,它接受另一個函數作為參數,並返回該函數只能被調用一次的新版本。
所得到的函數的後續調用應該沒有任何效果(而且應該返回undefined)
For example:

function foo() {
   console.log('foo');
}

fooOnce = once(foo) // 把foo傳入once得到新函數fooOnce 
fooOnce() // -> "foo"  (第一次調用fooOnce)
fooOnce() // -> no effect (第二次以後調用fooOnce 沒有任何效果)

by Larry Huang

@vampireneo
Copy link
Member

PASS

1 similar comment
@jawayang
Copy link
Contributor Author

PASS

@jawayang jawayang self-assigned this May 31, 2016
@bucker
Copy link

bucker commented Jun 7, 2016

pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants