-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuns2.html
More file actions
63 lines (49 loc) · 1.25 KB
/
funs2.html
File metadata and controls
63 lines (49 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
62
63
<!DOCTYPE html>
<html lang="em">
<head>
<script src="exprfuns.js"></script>
</head>
<body>
<h3>demo on expr functions</h3>
<script>
document.write(`${add}<br>`);
document.write(`${add(10,20)}<br>`);
document.write(`${product(15,9)}<br>`);
const eles=[6,100,23,80,505];
//callback or extending the functionality
eles.forEach(
function(e){
console.log(`EF`);
document.writeln(`${e} `);
}
);
let s=0;
eles.forEach(
function(e){
s+=e;
}
);
document.write(`<br>sum of eles: ${s}`);
//callback
eles.sort(function(i,j){
console.log(`sort`);
return i-j;//ascending
}
);
document.write(`<br>sorted arr: ${eles}`);
//callback
eles.sort(function(i,j){
console.log(`sort`);
return j-i;//decending
}
);
document.write(`<br>sorted arr: ${eles}<br>`);
</script>
<button id="bt">Click here</button>
<script>
bt.onclick=function(){
alert("button onclicked");
}
</script>
</body>
</html>