forked from AdamMomen/warmUp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarmup5.js
More file actions
60 lines (41 loc) · 1.2 KB
/
Copy pathwarmup5.js
File metadata and controls
60 lines (41 loc) · 1.2 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
// 1-create a data model to represent your classmates
function classmates (First_name, Last_name, Age, Gender, Education, City, Country){
return {
First_name: First_name,
Last_name: Last_name,
Age: Age,
Gender: Gender
Education: Education,
City: City,
Country: Country
}
}
var ClassMates = [];
function displayFriend(classmate){
return classmate[First_name] + classmate[Last_name] + " is a " + classmate[Age] + " year old " + classmate[Gender] + " with a degree in " + classmate[Education] + " from " + classmate[City] + ", " + classmate[Country]
}
function addFriend (mate){
ClassMates.push(mate);
}
function nbOfMale (classmates){
var acc= []
for (var i = 0; i < classmates.length; i++) {
if (classmates[i][Gender]=== "Male"){
acc.push(classmates[i]);
}
}
return acc.length;
}
function searchMates(attr, array) {
var acc= []
for (var i = 0; i < array.length; i++) {
for (key in array[i]) {
if (array[i][key] === attr){
acc.push(array[i]);
}
}
}
return acc;
}
// -Write a function searchMates that, given a query and an array of Mates,
// searches the array of mates for "matching" mate. You will decide what way you want to write your search algorithm.