-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathassignment13.js
More file actions
48 lines (30 loc) · 915 Bytes
/
assignment13.js
File metadata and controls
48 lines (30 loc) · 915 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
40
41
42
43
44
45
46
47
48
// JavaScript methods to boost skills
// Iterator in javascripts
const toolBox = ['Hammer', 'Screwdriver', 'Ruler'];
for(const item of toolBox) {
console.log(item);
}
// Map() method
const productPriceList = [200, 350, 1500, 5000];
productPriceList.map(function(item) {
return item * 0.75;
});
console.log("Product Price List", productPriceList);
// Filter() method
const price = [25, 30, 15, 55, 40, 10];
const filterPrice = price.filter(function(price){
return price >= 30;
});
console.log("Price", filterPrice);
// Reduce() method
const weeklyExpenses = [200, 350, 1500, 5000, 450, 680, 350];
const resultData = weeklyExpenses.reduce(function(first, last){
return first + last;
});
console.log("Result Data", resultData);
// Every() method
const age = [15, 20, 19];
const personAge = age.every(function(person){
return person > 18;
});
console.log("Persona Age", personAge);