-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmrf.js
More file actions
39 lines (25 loc) · 840 Bytes
/
mrf.js
File metadata and controls
39 lines (25 loc) · 840 Bytes
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
// map
// syntax
// variable name.map()(value,index,actualarray)=>) : v i a is an sample for value, index and actual array
// [map] method i is an integer with 0, 1, 2, 3, 4 in each box : 0+5 =5, 1+5=6, 2+5=7
let a = [10,20,30,40,50]
let b = a.map((v,i,a)=>i+5)
console.log(b);
let a =[10,20,30,40,50,60]
let b=a.map((v,i,a)=>v-5)
console.log(b);
// [Filter ]: task use comparision operator
// syntax value, index , array , itteration
let a = [10,20,30,40,50]
let b = a.filter((v,i,a)=>v>=40)
console.log(b);
let ab =[20,40,80,100]
let cv =ab.filter((v,i,a)=>v>=80)
console.log(cv);
let a = [10,20,30,40,50]
let b = a.filter((v,i,a)=>v>=40)
console.log(b);
/// [reduce method] - reduce means getting array value finds the array value
let red = [10,20,30,40,50]
let ret = red.reduce((x,y)=>x+y)
console.log(ret);