-
Notifications
You must be signed in to change notification settings - Fork 0
/
string-object-manipulation-1
71 lines (58 loc) · 1.34 KB
/
string-object-manipulation-1
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
66
67
68
69
70
71
function concatString(arguments){
return Array.prototype
.slice
.call(arguments,1)
.join(',');
}
function yourFunctionRunner(functions){
var func = Array.prototype.slice.call(arguments,1).join(',');
return func
.map(function call(func){return call(func);}); //not sure about this return func
.join('');
}
function makeAdder(base){
return function(num){
return base + num;
};
}
function once(fn){
var status = false;
return once(status){
if(status === false){
fn();
status = true;
}
};
}
function createObjectWithClosures(){
var sum = 0;
return {
oneIncrementer: function one(){ sum +=1;},
tensIncrementer: function two(){ sum += 10;},
getValue: function getVal(){ return sum;},
setValue: function setVal(value){ return sum + value;}
};
}
function guestListFns(guestArray, secretCode){
var finalGuests =[];
var checker = function checker(guest, sum){
return function checker(sum){
if(sum === secretCode){
return '"' + guest + '"';
}else{
return 'Secret-Code: Invalid';
}
};
};
for(var i = 0; i < guestArray.length; i += 1){
function cloGuest(){
return checker(guest,sum);
})
cloGuest(guestArray[i]);
}
}
return finalGuests;
}
function generateGuestLists(guestListFns, secretCode){
return guestListFns.map(function checkNames(checker, secretCode){ return checker(secretCode);};
}