forked from jsmapr1/simplifying-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrest.js
More file actions
61 lines (52 loc) · 1.25 KB
/
Copy pathrest.js
File metadata and controls
61 lines (52 loc) · 1.25 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
/* eslint-disable no-console, no-unused-vars, no-undef */
// START:arguments
function getArguments(...args) {
return args;
}
getArguments('Bloomsday', 'June 16');
// ['Bloomsday', 'June 16']
// END:arguments
// START:func
function validateCharacterCount(max, ...items) {
return items.every(item => item.length < max);
}
// END:func
// START:example
validateCharacterCount(10, 'wvoquie');
// true
validateCharacterCount(10, ...['wvoquie']);
// true
const tags = ['Hobbs', 'Eagles'];
validateCharacterCount(10, ...tags);
// true
validateCharacterCount(10, 'Hobbs', 'Eagles');
// true
// END:example
function debug() {
// START:debug
['Spirited Away', 'Princess Mononoke'].map((film, ...other) => {
console.log(other);
return film.toLowerCase();
});
// [0, ['Spirited Away', 'Princess Mononoke']]
// [1, ['Spirited Away', 'Princess Mononoke']]
// END:debug
}
function shift() {
// START:shift
const queue = ['stop', 'collaborate', 'listen'];
const [first, ...remaining] = queue;
first;
// 'stop'
remaining;
// ['collaborate', 'listen'];
// END:shift
return [first, remaining];
}
// START:pass
function applyChanges(...args) {
updateAccount(...args);
closeModal();
}
// END:pass
export { getArguments, shift, validateCharacterCount };