-
Notifications
You must be signed in to change notification settings - Fork 201
/
practice.js
69 lines (40 loc) · 1.41 KB
/
practice.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//Once you complete a problem, open up Chrome and check the answer in the console.
var outer = function(){
var name = 'Tyler';
return function(){
return 'The original name was ' + name;
}
}
//Above you're given a function that returns another function which has a closure over the name variable.
//Invoke outer saving the return value into another variable called 'inner'.
//Code Here
//Once you do that, invoke inner.
//Code Here
//Next problem
var callFriend = function(){
var friend = 'Jake';
function callF(number){
return 'Calling ' + friend + ' at ' + number;
}
return callF;
};
//Above you're given a callFriend function that returns another function.
//Do what you need to do in order to call your function and get 'Calling Jake at 435-215-9248' in your console.
//Code Here
//Next Problem
/*
Write a function called makeCounter that makes the following code work properly.
*/
//Code Here
var count = makeCounter();
count() // 1
count() // 2
count() // 3
count() // 4
//Next Problem
/*
Write a function that accepts another function as it's first argument and returns a new function
(which invokes the original function that was passed in) that can only ever be executed once.
Once completed, add a second argument that allows the function to be invoked N number of times.
After the function has been called N number of times, console.log('STAHHP');
*/