-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_function3.js
More file actions
50 lines (43 loc) · 1.25 KB
/
array_function3.js
File metadata and controls
50 lines (43 loc) · 1.25 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
// //1st
// let numbers=[2,5,6,7,8,9];
// let evenNumbers=numbers.filter(ele=>ele%2==0)
// console.log(evenNumbers)
//2nd
// const studentData=[
// {name:"Alice",score:88},
// {name:"Bob",score:92},
// {name:"Charlie",score:75},
// {name:"David",score:64}
// ]
// function assignGrades(students){
// return students.map((student)=>{
// let newStudent={...student};
// if(newStudent.score>=90){
// newStudent.grade="A";
// }
// else if(newStudent.score>=80 && newStudent.score<=89){
// newStudent.grade="B";
// }
// else if(newStudent.score>=70 && newStudent.score<=79){
// newStudent.grade="C";
// }
// else{
// newStudent.grade="D";
// }
// return newStudent;
// })
// }
// const gradedStudents=assignGrades(studentData);
// console.log(gradedStudents)
//3rd
// const inventory=[
// { name: "Laptop", price: 800 },
// { name: "Phone", price: 600 },
// { name: "Tablet", price: 300 }
// ]
// const totalPrice = inventory.reduce((acc,ele)=>acc+ele.price,0)
// console.log(totalPrice)
//4th
const ages=[25,30,90,21,19]
console.log(ages.some((ele)=>ele>=18))
console.log(ages.every((ele)=>ele>=18))