-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
153 lines (113 loc) · 2.93 KB
/
Copy pathindex.html
File metadata and controls
153 lines (113 loc) · 2.93 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="ES6 Exercise: rest/spread">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<h1>Test Results</h1>
<script src="https://wzrd.in/standalone/tap-browser-color@latest"></script>
<script src="https://wzrd.in/standalone/tape@latest"></script>
<script id="jsbin-javascript">
// This will colour the body red/green/yellow to indicate test status.
'use strict';
tapBrowserColor();
/**
* ES5 Version of rest parameters
* (the old syntax)
*/
var sum = undefined;
sum = function () {
var total = 0;
for (var i = 0; i < arguments.length; i++) {
total = total + arguments[i];
}
return total;
};
/**
* ES6 Version of Rest Parameters
*/
// TODO: Uncomment the below and flesh it out using ES6 syntax
// and see if the test still passes.
// sum = function ( ...values ) {};
/**
* Tests of Rest Parameters
*/
tape('rest parameters', function (t) {
var res = sum(1, 2, 3);
t.equal(res, 6, 'should total all numbers provided');
t.end();
});
/**
* ES5 Version of spread
* (the old syntax)
*/
var sumArray = undefined;
sumArray = function (array) {
return total = sum.apply(this, array);
};
/**
* ES6 Version of Rest Parameters
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters
*/
// TODO: Uncomment the below and flesh it out using ES6 syntax
// and see if the test still passes.
// sumArray = function ( values ) {};
tape('spread', function (t) {
var res = sumArray([1, 2, 3]);
t.equal(res, 6, 'should total all numbers provided');
t.end();
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">// This will colour the body red/green/yellow to indicate test status.
tapBrowserColor();
/**
* ES5 Version of rest parameters
* (the old syntax)
*/
let sum;
sum = function () {
let total = 0;
for ( let i = 0; i < arguments.length; i++ ) {
total = total + arguments[i];
}
return total;
};
/**
* ES6 Version of Rest Parameters
*/
// TODO: Uncomment the below and flesh it out using ES6 syntax
// and see if the test still passes.
// sum = function ( ...values ) {};
/**
* Tests of Rest Parameters
*/
tape( 'rest parameters', t => {
const res = sum( 1, 2, 3 );
t.equal( res, 6, 'should total all numbers provided' );
t.end();
});
/**
* ES5 Version of spread
* (the old syntax)
*/
let sumArray;
sumArray = function ( array ) {
return total = sum.apply( this, array );
};
/**
* ES6 Version of Rest Parameters
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters
*/
// TODO: Uncomment the below and flesh it out using ES6 syntax
// and see if the test still passes.
// sumArray = function ( values ) {};
tape( 'spread', t => {
const res = sumArray([ 1, 2, 3 ]);
t.equal( res, 6, 'should total all numbers provided' );
t.end();
});
</script></body>
</html>