-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path08-Higher Order Functions - JavaScript Tutorial.js
More file actions
53 lines (42 loc) · 1.18 KB
/
08-Higher Order Functions - JavaScript Tutorial.js
File metadata and controls
53 lines (42 loc) · 1.18 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
// const names = ['Sina', 'Sam', 'Qoli', 'Ben', 'Zoe', 'Quentin', 'Ala']
// names.filter(n => n[0] !== 'Q')
// .filter(n => n.length >= 5)
// .map(n => {
// const el = document.createElement('p')
// el.innerText = n
// return el
// })
// names.filter(isNotQ)
// .filter(isMinimum5)
// .map(convertToEl)
// function isNotQ(n) {
// return n[0] !== 'Q'
// }
// function isMinimum5(n) {
// return n.length >= 5
// }
// function convertToEl(n) {
// const el = document.createElement('p')
// el.innerText = n
// return el
// }
{/* <button onclick="onClick12">12px</button> */}
{/* <button onclick="onClick14">14px</button> */}
{/* <button onclick="onClick16">16px</button> */}
// function onClick12() {
// document.body.style.fontSize = '12px'
// }
// function onClick14() {
// document.body.style.fontSize = '14px'
// }
// function onClick16() {
// document.body.style.fontSize = '16px'
// }
const onClick12 = makeClickHandler(12)
const onClick14 = makeClickHandler(14)
const onClick16 = makeClickHandler(16)
function makeClickHandler(size) {
return function() {
document.body.style.fontSize = `${size}px`
}
}