-
Notifications
You must be signed in to change notification settings - Fork 3
/
Day6.docx
114 lines (78 loc) · 1.9 KB
/
Day6.docx
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//OOPS --> Object Oriented Programming
// class --> Blueprint
// object --> An model create based on the blueprint
// class Myclass{
// constructor(x,y,z=10){
// this.a = x
// this.b = y
// this.c = z
// }
// add(){
// return this.a + this.b
// }
// }
// let obj1 = new Myclass(30,40)
// let obj2 = new Myclass(2,4,3)
// console.log(`${obj1.a} + ${obj1.b} = ${obj1.add()}`)
// console.log(obj2.a,obj2.b,obj2.c,obj2.add())
// let a = [1,2,3,4]
// let b = [10,20,30,40]
// console.log(a.join(""),b.length)
// class MyArray {
// constructor(a)
// {
// this.len = 0
// for(let i in a)
// this.len++
// }
// insert(n)
// {
// this.length++
// }
// del(n)
// {
// this.length--
// }
// }
// let x = [10,20,30,40]
// let a = new MyArray(x)
// console.log(a.len)
// let a = new Array(10,20,30,40)
// console.log(a)
// let a = [10,20,30]
// class Abc{
// print(a,b)
// {
// console.log("Hi I am print",a,b)
// }
// }
// let obj1 = new Abc()
// obj1.print(10,20)
//setter and getter
// https://www.programiz.com/javascript/getter-setter
// let a = ["Hello","How","are","you","I","am","fine"]
// let lengths = a.map((e)=>
// {
// return e.length
// })
// console.log(lengths)
// let a = ["Hello","How","are","you","I","am","fine"]
// let filteredData = a.filter((e)=>e.length==3)
// console.log(filteredData)
// let filteredData = a.filter((e)=>{
// if(e.length>3)
// return true
// })
// console.log(filteredData)
// let a = [1,2,3,4,5]
// let sum = 0
// for(let i=0;i<a.length;i++)
// {
// sum = sum + a[i]
// }
let a = [1,2,3,4,5]
let sum = a.reduce((accumulator,currentValue)=>{
return accumulator*currentValue
})
console.log(sum)
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array