-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathfunctions.js
More file actions
37 lines (32 loc) · 1.08 KB
/
functions.js
File metadata and controls
37 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
creates a function that invokes theFunc once it's called n or more times
in the after function, create a variable to be a counter
create a new function called theAfter in the after function
when theAfter is called increment the counter
if counter === times, call theFunc()
return the theAfter
*/
export function after(times, theFunc){
}
/*
creates a function that invokes theFunc while it's called n or less times
create a variable to be a counter
create a new function called theBefore in the before function
when theBefore is called increment the counter
if counter <= times, call theFunc()
return the theBefore
*/
export function before(times, theFunc){
}
/*
Creates a function that is restricted to invoking theFunc once.
Repeat calls to the function return the value of the first invocation.
create a variable called firstValue and set it to null
create a new function called theOnce
in theOnce check if firstValue is null,
if so call theFunc and assign the returned value into firstValue
return firstValue
return theOnce
*/
export function once(theFunc){
}