-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray2.js
More file actions
68 lines (61 loc) · 1.65 KB
/
Copy patharray2.js
File metadata and controls
68 lines (61 loc) · 1.65 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
64
65
66
67
68
//? map,filter,find,findIndex,reduce
//? loop based
// let studentList = ["Saugat", "Shubham", "Smarika", "Unik", "Smriti", "Utsarga"];
// studentList.map((item, index, array) => {
// console.log(item, index, array);
// });
//? map => it return new array
//? to alter the values of array
//? original array length === returned array length
// const newStudentList= studentList.map((item,index,array)=>{
// return 0;
// });
// console.log(newStudentList)
// const newStudentList1=studentList.map((item,index,array)=>{
// let uppercaseName=item.toUpperCase();
// return uppercaseName;
// });
// console.log(newStudentList1)
// const priceList=[25,34,56,22,38,97,100];
// //? increase price of every item by 3 dollar
// const newPriceList=priceList.map((item,index,array)=>{
// let increasedItem=item+3;
// return increasedItem;
// //? SAME CODE
// //? const newPriceList=priceList.map((item)=>item+3);
// });
// console.log(newPriceList);
//? array of object
const productList=[
{
id:1,
name:"Night Vision Glass",
Price:4,
},
{
id:2,
name:"Gloves",
Price:5,
},
{
id:3,
name:"Helmet",
Price:24,
},
];
//? increase price by 10%
// const newPrice=productList.map((item,index,array)=>{
// let increasedPrice=item.Price+0.1*item.Price;
// return {
// ...item,
// //?id=item.id,
// //?name=item.name,
// Price:increasedPrice,
// }
// });
// console.log(newPrice);
//? find all items whose price is less than 10
const newPrice=productList.filter((item,index,array)=>{
return item.Price<10;
});
console.log(newPrice)