-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclosure.html
More file actions
74 lines (63 loc) · 1.89 KB
/
Copy pathclosure.html
File metadata and controls
74 lines (63 loc) · 1.89 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Closure aur chai</title>
</head>
<body style="background-color: #313131;">
<button id="orange">Orange</button>
<button id="green">Green</button>
</body>
<script>
// function init() {
// let name = "Mozilla";
// function displayName() {
// console.log(name);
// }
// displayName();
// }
// init();
// function outer(){
// let username = "aliza"
// console.log("OUTER", secret);
// function inner(){
// let secret = "my123"
// console.log("inner", username);
// }
// function innerTwo(){
// console.log("innerTwo", username);
// console.log(secret);
// }
// inner()
// innerTwo()
// }
// outer()
// console.log("TOO OUTER", username);
// function makeFunc() {
// const name = "Mozilla";
// function displayName() {
// console.log(name);
// }
// return displayName;
// }
// const myFunc = makeFunc();
// myFunc();
</script>
<script>
// document.getElementById("orange").onclick = function(){
// document.body.style.backgroundColor = `orange`
// }
// document.getElementById("green").onclick = function(){
// document.body.style.backgroundColor = `green`
// }
function clickHandler(color){
// document.body.style.backgroundColor = `${color}`
return function(){
document.body.style.backgroundColor = `${color}`
}
}
document.getElementById('orange').onclick = clickHandler("orange")
document.getElementById('green').onclick = clickHandler("green")
</script>
</html>