-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest
More file actions
78 lines (65 loc) · 2.22 KB
/
test
File metadata and controls
78 lines (65 loc) · 2.22 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
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
72
73
74
75
76
77
//--------------------------------------------------------
// 1. argsSum()
// Takes N arguments, and should work on any number of arguments
//--------------------------------------------------------
result = argsSum(3,7,8);
console.log(result); // 18
result = argsSum(1,1,1,1,1,1,1,1,1,1,1,1,1,1);
console.log(result); // 14
(function argsSum(N){
var arr = N.split(/\ b/);
return N = arr.map(Math.sum());
}
console.log(argsSum(3,7,8));)
//--------------------------------------------------------
// 2. splitSum()
// Takes 2 arguments
//--------------------------------------------------------
result = splitSum("3:4:5:1", ":");
console.log(result); // 13
result = splitSum("-1$-5$5$-4", "$");
console.log(result); // -5
//--------------------------------------------------------
// 3. createArray()
// Takes 2 arguments
//--------------------------------------------------------
result = createArrayFromAtoB(4, 9);
console.log(result); // [4, 5, 6, 7, 8, 9]
result = createArrayFromAtoB(-1, 3);
console.log(result); // [-1, 0, 1, 2, 3]
result = createArrayFromAtoB(4, 9);
console.log(result); // [4, 5, 6, 7, 8, 9]
result = createArrayFromAtoB(-1, 3);
console.log(result); // [-1, 0, 1, 2, 3]
(function createArrayFromAtoB(N){
var result = N.split(" ");)}
//--------------------------------------------------------
// 4. isTodayAWeekend()
// Takes no arguments
//--------------------------------------------------------
result = isTodayAWeekend();
console.log(result);
// It will return true if today is Saturday or Sunday, otherwise, false
(var test = new Date();
var today = test.getDay();
function date(result){
if(1 <=today<=5){
return result === today;
}
else{
return result!=today;
}
};
console.log(date(today));)
//--------------------------------------------------------
// 5. Array.map
//--------------------------------------------------------
// Fill in the array below to make the output of the map the word "CODING"
var array = [];
var key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
result = array.map(function(e) { return key[e/2]; }).join('');
console.log(result); // CODING
(var array = [4,28,6,16,26,12];
var key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
result = array.map(function(e) { return key[e/2]; }).join('');
console.log(result); )