ajout tp2mvc, tp3 et update des tp 1 et 2
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
let customers = [
|
||||
{
|
||||
'id': 1,
|
||||
'f_name': 'Abby',
|
||||
'l_name': 'Thomas',
|
||||
'gender': 'M',
|
||||
'married': true,
|
||||
'age': 32,
|
||||
'expense': 500,
|
||||
'purchased': ['Shampoo', 'Toys', 'Book']
|
||||
},
|
||||
{
|
||||
'id': 2,
|
||||
'f_name': 'Jerry',
|
||||
'l_name': 'Tom',
|
||||
'gender': 'M',
|
||||
'married': true,
|
||||
'age': 64,
|
||||
'expense': 100,
|
||||
'purchased': ['Stick', 'Blade']
|
||||
},
|
||||
{
|
||||
'id': 3,
|
||||
'f_name': 'Dianna',
|
||||
'l_name': 'Cherry',
|
||||
'gender': 'F',
|
||||
'married': true,
|
||||
'age': 22,
|
||||
'expense': 1500,
|
||||
'purchased': ['Lipstik', 'Nail Polish', 'Bag', 'Book']
|
||||
},
|
||||
{
|
||||
'id': 4,
|
||||
'f_name': 'Dev',
|
||||
'l_name': 'Currian',
|
||||
'gender': 'M',
|
||||
'married': true,
|
||||
'age': 82,
|
||||
'expense': 90,
|
||||
'purchased': ['Book']
|
||||
},
|
||||
{
|
||||
'id': 5,
|
||||
'f_name': 'Maria',
|
||||
'l_name': 'Gomes',
|
||||
'gender': 'F',
|
||||
'married': false,
|
||||
'age': 7,
|
||||
'expense': 300,
|
||||
'purchased': ['Toys']
|
||||
},
|
||||
{
|
||||
'id': 6,
|
||||
'f_name': 'Homer',
|
||||
'l_name': 'Simpson',
|
||||
'gender': 'M',
|
||||
'married': true,
|
||||
'age': 39,
|
||||
'expense': 500,
|
||||
'purchased': ['Book']
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
|
||||
// Question 1 :
|
||||
function filterOldPeople(customers) {
|
||||
customers.filter(returnOldPeople);
|
||||
}
|
||||
|
||||
function returnOldPeople(customer) {
|
||||
return customer.age > 60;
|
||||
}
|
||||
|
||||
let oldCustomers = filterOldPeople(customers);
|
||||
//console.log(oldCustomers);
|
||||
|
||||
// Question 2 :
|
||||
function fullName(customer) {
|
||||
customer.full_name = customer.f_name +" "+ customer.l_name;
|
||||
}
|
||||
|
||||
customers.forEach(fullName);
|
||||
//console.log(customers);
|
||||
|
||||
//Question 3 :
|
||||
function isUnderTen(customer) {
|
||||
return customer.age < 10;
|
||||
}
|
||||
|
||||
customers.some(isUnderTen);
|
||||
Reference in New Issue
Block a user