-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuns3.html
More file actions
60 lines (44 loc) · 1.26 KB
/
funs3.html
File metadata and controls
60 lines (44 loc) · 1.26 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
<!DOCTYPE html>
<html lang="em">
<head>
<script src="arrowfuns.js"></script>
</head>
<body>
<h3>demo on arrow functions</h3>
<script>
myfun();//calling
document.write(`${add(10,20)}<br>`);
document.write(`${product(15,9)}<br>`);
document.write(`${natsum(15)}<br>`);
document.write(`${area(2)}<br>`);
const eles=[90,55,100,30];
eles.forEach(
(x)=>{
document.writeln(`${x}`);
}
);
let s=0;
eles.forEach(e=>s+=e);
document.write(`<br>sum of eles: ${s}`);
//callback
eles.sort((i,j)=> i-j );
document.write(`<br>sorted arr: ${eles}`);
//callback
eles.sort((i,j)=>j-i);
document.write(`<br>sorted arr: ${eles}<br>`);
const a=[1,2,3,4,5,6,7,8,9,10];
let even=a.filter((e=>e%2==0));//it is also new feature like forEach
let odd=a.filter((e=>e%2!=0));
document.write(`Even: ${even}<br>`);
document.write(`Odd: ${odd}<br>`);
let b=[2,3,8,15];
document.write(`B: ${b}<br>`);
b=b.map(e=>e*2);
document.write(`B: ${b}<br>`);
</script>
<button id="bt">Click here</button>
<script>
bt.onclick=()=>alert("button onclicked");
</script>
</body>
</html>